How to display Developer Express designed the form of XtraReport

XtraReport designer, in fact, with XRDesignFormEx or XRDesignRibbonFormEx can. Mainly to see what kind of style like. The two classes must be a reference

DevExpress.XtraReports.v (version) .Extensions and DevExpress.XtraReports.v (version) of 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();
        }
    }
}

In this way we will be able to control what and when you load the destruction of the design of the form, you can override the data inside. Such as design form displays a bit slow, we wait to load a form in the beginning, appear close after this
display of waiting for the form. There are other events, as the case may be. (Reference http://www.cnblogs.com/rock_chen/archive/2008/7/2.html) on the template design and data bindings can see the previously published

Developer Express XtraReport how the data dynamic binding.

Reproduced in: https: //my.oschina.net/cookblack/blog/621381

Guess you like

Origin blog.csdn.net/weixin_34138521/article/details/92046072