-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
47 lines (44 loc) · 2.01 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
using DevExpress.XtraReports;
using DevExpress.XtraReports.Extensions;
using DevExpress.XtraReports.UI;
// ...
namespace WindowsApplication54 {
public partial class Form1 : Form {
static Form1() {
// The following code is required to support serialization of multiple custom objects.
TypeDescriptor.AddAttributes(typeof(DataSet), new ReportAssociatedComponentAttribute());
TypeDescriptor.AddAttributes(typeof(OleDbDataAdapter), new ReportAssociatedComponentAttribute());
// The following code is required to serialize custom objects.
ReportExtension.RegisterExtensionGlobal(new ReportExtension());
ReportDesignExtension.RegisterExtension(new DesignExtension(), ExtensionName);
}
private const string ExtensionName = "Custom";
public Form1() {
InitializeComponent();
}
private void createReportWhithDataSourceButton_Click(object sender, EventArgs e) {
using(XtraReport report = new XtraReport()) {
using(ReportDesignTool tool = new ReportDesignTool(report)) {
tool.DesignForm.DesignMdiController.DesignPanelLoaded += OnDesignPanelLoaded;
tool.ShowDesignerDialog();
}
}
}
void OnDesignPanelLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) {
ReportDesignExtension.AssociateReportWithExtension((XtraReport)e.DesignerHost.RootComponent, ExtensionName);
}
private void loadReportfromFileButton_Click(object sender, EventArgs e) {
OpenFileDialog openfd = new OpenFileDialog();
if (openfd.ShowDialog() != DialogResult.OK)
return;
XtraReport report = new XtraReport();
report.LoadLayoutFromXml(openfd.FileName);
report.ShowDesignerDialog();
}
}
}