/
ChildReport.cs
35 lines (32 loc) · 1.5 KB
/
ChildReport.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
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
namespace TreeViewReport {
public partial class ChildReport : DevExpress.XtraReports.UI.XtraReport {
public ChildReport() {
InitializeComponent();
}
private void xrSubreport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
XRSubreport subReport = sender as XRSubreport;
ParentNode parentNode = this.GetCurrentRow() as ParentNode;
ChildReport childReport = new ChildReport();
childReport.Parameters["Level"].Value = this.Parameters["Level"].Value;
childReport.DataSource = parentNode.Children;
subReport.ReportSource = childReport;
childReport.ReduceControlSize(subReport, parentNode.Level);
}
void ReduceControlSize(XRSubreport subreport, int level) {
XtraReport report = subreport.ReportSource;
report.PaperKind = System.Drawing.Printing.PaperKind.Custom;
report.PageWidth = (int)(PrintingSystem.PageSettings.UsablePageSize.Width - subreport.LocationF.X * (level - 1) + report.Margins.Right);
subreport.WidthF = report.PageWidth;
foreach(Band band in report.Bands)
foreach(XRControl control in band.Controls) {
if(control is XRTable)
(control as XRTable).WidthF = subreport.SizeF.Width;
}
}
}
}