Developer Express 之 XtraReport如何顯示設(shè)計(jì)窗體
XtraReport的設(shè)計(jì)器,其實(shí)用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 ; //這個(gè)可以是加載之前設(shè)計(jì)好的模板 |
19 |
public Form1() |
20 |
{ |
21 |
InitializeComponent(); |
22 |
} |
23 |
|
24 |
private void designForm_FormClosing( object sender, FormClosingEventArgs e) |
25 |
{ |
26 |
//在此處處理關(guān)閉設(shè)計(jì)器時(shí)的操作,主要用來自定義保存數(shù)據(jù) |
27 |
//r.SaveLayout(@"C:\1.repx"); |
28 |
} |
29 |
|
30 |
private void designForm_ReportStateChanged( object sender, ReportStateEventArgs e) |
31 |
{ |
32 |
//只要報(bào)表發(fā)生改變就立即將狀態(tài)設(shè)置為保存 |
33 |
//避免系統(tǒng)默認(rèn)保存對(duì)話框的出現(xiàn) |
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 |
//更改狀態(tài) |
56 |
designForm.ReportStateChanged += new ReportStateEventHandler(designForm_ReportStateChanged); |
57 |
|
58 |
designForm.FormClosing += new FormClosingEventHandler(designForm_FormClosing); |
59 |
|
60 |
// 加載報(bào)表. |
61 |
designForm.OpenReport(r); |
62 |
|
63 |
// 打開設(shè)計(jì)器 |
64 |
designForm.ShowDialog(); |
65 |
|
66 |
designForm.Dispose(); |
67 |
} |
68 |
} |
69 |
} |
70 |
<SPAN style= "FONT-FAMILY: 微軟雅黑" >這樣我們就能在加載和銷毀設(shè)計(jì)窗體的時(shí)候要控制什么,你可以重載里面的數(shù)據(jù)。比如設(shè)計(jì)窗體顯示有點(diǎn)慢,我們?cè)陂_始的時(shí)候加載個(gè)等待窗體,顯示出來后關(guān)閉這個(gè)</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>)關(guān)于模板的設(shè)計(jì)和數(shù)據(jù)綁定可以參看之前發(fā)表的</SPAN> |
1 |
Developer Express 之 XtraReport如何數(shù)據(jù)動(dòng)態(tài)綁定。 |