-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
66 lines (58 loc) · 2.57 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using System.IO;
using DevExpress.XtraReports.UserDesigner;
using DevExpress.XtraCharts;
namespace WindowsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
XtraReport ActiveReport;
private void Form1_Load(object sender, EventArgs e) {
this.xtraUserControl11.xrDesignPanel1.OpenReport(new XtraReport1());
this.xtraUserControl11.xrDesignPanel1.SetCommandVisibility(ReportCommand.ShowPreviewTab,CommandVisibility.None);
this.xtraUserControl11.xrDesignPanel1.SetCommandVisibility(ReportCommand.ShowHTMLViewTab,CommandVisibility.None);
this.xtraUserControl11.xrDesignPanel1.SetCommandVisibility(ReportCommand.ShowDesignerTab, CommandVisibility.None);
}
private void xtraTabControl1_SelectedPageChanging(object sender, DevExpress.XtraTab.TabPageChangingEventArgs e) {
if(e.PrevPage.Text == "Design") {
if( this.xtraUserControl11.xrDesignPanel1.Report == null)
e.Cancel = true;
else {
MemoryStream ms = new MemoryStream();
try{
this.xtraUserControl11.xrDesignPanel1.Report.SaveLayout(ms);
ms.Seek(0, SeekOrigin.Begin);
ActiveReport = XtraReport.FromStream(ms, true);
ActiveReport.DataSource = this.xtraUserControl11.xrDesignPanel1.Report.DataSource ;
ActiveReport.DataMember = this.xtraUserControl11.xrDesignPanel1.Report.DataMember;
}
finally {
ms.Close();
}
}
}
if(e.Page.Text == "Preview") {
ActiveReport.CreateDocument();
this.xtraUserControl21.printControl1.PrintingSystem = ActiveReport.PrintingSystem;
}
if(e.Page.Text == "HTML View") {
try
{
ActiveReport.ExportToHtml(Environment.CurrentDirectory +"\\temp.html");
xtraUserControl31.webBrowser1.Navigate(Environment.CurrentDirectory + "\\temp.html");
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
}
}
}