Developer Express 之 XtraReport如何显示设计窗体
XtraReport的设计器,其实用XRDesignFormEx就可以。
01 |
using System; |
02 |
using System.Collections.Generic; |
03 |
using System.ComponentModel; |
04 |
using System.Data; |
05 |
using System.Drawing; |
06 |
using System.Linq; |
07 |
using System.Text; |
08 |
using System.Windows.Forms; |
09 |
using DevExpress.XtraReports.UI; |
10 |
using DevExpress.XtraReports.UserDesigner; |
11 |
using System.Drawing.Design; |
12 |
using System.ComponentModel.Design; |
13 |
|
14 |
namespace WFAXtraReport |
15 |
{ |
16 |
public partial class Form1 : Form |
17 |
{ |
18 |
XtraReport r ; //这个可以是加载之前设计好的模板 |
19 |
public Form1() |
20 |
{ |
21 |
InitializeComponent(); |
22 |
} |
23 |
|
24 |
private void designForm_FormClosing( object sender, FormClosingEventArgs e) |
25 |
{ |
26 |
//在此处处理关闭设计器时的操作,主要用来自定义保存数据 |
27 |
//r.SaveLayout(@"C:\1.repx"); |
28 |
} |
29 |
|
30 |
private void designForm_ReportStateChanged( object sender, ReportStateEventArgs e) |
31 |
{ |
32 |
//只要报表发生改变就立即将状态设置为保存 |
33 |
//避免系统默认保存对话框的出现 |
34 |
if (e.ReportState == ReportState.Changed) |
35 |
{ |
36 |
((XRDesignFormEx)sender).DesignPanel.ReportState = ReportState.Saved; |
37 |
} |
38 |
} |
39 |
|
40 |
private void Form1_Load( object sender, EventArgs e) |
41 |
{ |
42 |
r = new XtraReport(); |
43 |
//r.LoadLayout(@"C:\1.repx"); |
44 |
XRDesignFormEx designForm = new XRDesignFormEx(); |
45 |
|
46 |
//隐藏按钮 |
47 |
designForm.DesignPanel.SetCommandVisibility( new ReportCommand[]{ |
48 |
ReportCommand.NewReport, |
49 |
ReportCommand.SaveFileAs, |
50 |
ReportCommand.NewReportWizard, |
51 |
ReportCommand.OpenFile |
52 |
}, CommandVisibility.None); |
53 |
|
54 |
|
55 |
//更改状态 |
56 |
designForm.ReportStateChanged += new ReportStateEventHandler(designForm_ReportStateChanged); |
57 |
|
58 |
designForm.FormClosing += new FormClosingEventHandler(designForm_FormClosing); |
59 |
|
60 |
// 加载报表. |
61 |
designForm.OpenReport(r); |
62 |
|
63 |
// 打开设计器 |
64 |
designForm.ShowDialog(); |
65 |
|
66 |
designForm.Dispose(); |
67 |
} |
68 |
} |
69 |
} |
70 |
<SPAN style= "FONT-FAMILY: 微软雅黑" >这样我们就能在加载和销毁设计窗体的时候要控制什么,你可以重载里面的数据。比如设计窗体显示有点慢,我们在开始的时候加载个等待窗体,显示出来后关闭这个</SPAN> |
1 |
<SPAN style= "FONT-FAMILY: 微软雅黑" >显示等待的窗体。还有其他的事件视情况而定。(参考<A href= "http://www.cnblogs.com/rock_chen/archive/2008/7/2.html" >http://www.cnblogs.com/rock_chen/archive/2008/7/2.html</A>)关于模板的设计和数据绑定可以参看之前发表的</SPAN> |
1 |
Developer Express 之 XtraReport如何数据动态绑定。 |