Developer Express 之 XtraReport如何显示设计窗体

XtraReport的设计器,其实用XRDesignFormEx或者是XRDesignRibbonFormEx就可以。主要看喜欢哪种风格。这个两个类必须是引用

DevExpress.XtraReports.v(版本).Extensions和DevExpress.XtraReports.v(版本)的dll

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using System.Drawing.Design;
using System.ComponentModel.Design;

namespace WFAXtraReport
{
    public partial class Form1 : Form
    {
        XtraReport r ;//这个可以是加载之前设计好的模板
        public Form1()
        {
            InitializeComponent();
        }

        private void designForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            //在此处处理关闭设计器时的操作,主要用来自定义保存数据
            //r.SaveLayout(@"C:\1.repx");
        }

        private void designForm_ReportStateChanged(object sender, ReportStateEventArgs e)
        {
            //只要报表发生改变就立即将状态设置为保存
            //避免系统默认保存对话框的出现
            if (e.ReportState == ReportState.Changed)
            {
                ((XRDesignFormEx)sender).DesignPanel.ReportState = ReportState.Saved;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            r = new XtraReport();
            //r.LoadLayout(@"C:\1.repx");
            XRDesignFormEx designForm = new XRDesignFormEx();

            //隐藏按钮
            designForm.DesignPanel.SetCommandVisibility(new ReportCommand[]{
                ReportCommand.NewReport,
                ReportCommand.SaveFileAs,
                ReportCommand.NewReportWizard,
                ReportCommand.OpenFile
            }, CommandVisibility.None);


            //更改状态
            designForm.ReportStateChanged += new ReportStateEventHandler(designForm_ReportStateChanged);

            designForm.FormClosing += new FormClosingEventHandler(designForm_FormClosing);

            // 加载报表. 
            designForm.OpenReport(r);

            // 打开设计器
            designForm.ShowDialog();

            designForm.Dispose();
        }
    }
}

这样我们就能在加载和销毁设计窗体的时候要控制什么,你可以重载里面的数据。比如设计窗体显示有点慢,我们在开始的时候加载个等待窗体,显示出来后关闭这个
显示等待的窗体。还有其他的事件视情况而定。(参考http://www.cnblogs.com/rock_chen/archive/2008/7/2.html)关于模板的设计和数据绑定可以参看之前发表的

Developer Express 之 XtraReport如何数据动态绑定。

转载于:https://my.oschina.net/cookblack/blog/621381

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值