-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
50 lines (41 loc) · 1.82 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
using System;
using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.UI;
namespace ReportParameterExample {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
}
private void simpleButton1_Click(object sender, EventArgs e) {
// Create a report instance.
XtraReport1 report = new XtraReport1();
// Create a parameter and specify its name.
Parameter param1 = new Parameter();
param1.Name = "CatID";
// Specify other parameter properties.
param1.Type = typeof(System.Int32);
param1.Value = 1;
param1.Description = "Category: ";
param1.Visible = true;
// Add the parameter to the report.
report.Parameters.Add(param1);
// Specify the report's filter string.
report.FilterString = "[CategoryID] = [Parameters.CatID]";
// Force the report creation without previously
// requesting the parameter value from end-users.
report.RequestParameters = false;
// Show the parameter's value on a Report Header band.
XRLabel label = new XRLabel();
label.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "Category: [CategoryName]"));
ReportHeaderBand reportHeader = new ReportHeaderBand();
reportHeader.Controls.Add(label);
report.Bands.Add(reportHeader);
// Assign the report to a ReportPrintTool,
// to hide the Parameters panel,
// and show the report's print preview.
ReportPrintTool pt = new ReportPrintTool(report);
pt.AutoShowParametersPanel = true;
pt.ShowPreviewDialog();
}
}
}