/
XtraReport1.cs
51 lines (43 loc) · 1.6 KB
/
XtraReport1.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
using System.Drawing;
using System.Drawing.Printing;
using DevExpress.XtraReports.UI;
// ...
namespace XRTable_RuntimeCreation {
public partial class XtraReport1 : XtraReport {
#region #Report Creation
public XtraReport1() {
InitializeComponent();
}
private void XtraReport1_BeforePrint(object sender, PrintEventArgs e) {
this.Detail.Controls.Add(CreateXRTable());
}
#endregion
public XRTable CreateXRTable() {
int cellsInRow = 3;
int rowsCount = 3;
float rowHeight = 25f;
XRTable table = new XRTable();
table.Borders = DevExpress.XtraPrinting.BorderSide.All;
table.BeginInit();
for (int i = 0; i < rowsCount; i++) {
XRTableRow row = new XRTableRow();
row.HeightF = rowHeight;
for (int j = 0; j < cellsInRow; j++) {
XRTableCell cell = new XRTableCell();
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
table.BeforePrint += new PrintEventHandler(table_BeforePrint);
table.AdjustSize();
table.EndInit();
return table;
}
// The following code makes the table span to the entire page width.
void table_BeforePrint(object sender, PrintEventArgs e) {
XRTable table = ((XRTable)sender);
table.LocationF = new DevExpress.Utils.PointFloat(0F, 0F);
table.WidthF = this.PageWidth - this.Margins.Left - this.Margins.Right;
}
}
}