Skip to main content

XRSubreport() Constructor

Initializes a new instance of the XRSubreport class with the default settings.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public XRSubreport()

Remarks

The code sample below adds an XRSubreport item to the report and uses the ReportSourceUrl property to reference a detail report.

Tip

Online Example: Use Subreports to Add a Chart

using System.IO;
using System.Drawing;
using DevExpress.XtraReports.UI;
// ...
XRSubreport subreport = new XRSubreport() {
    BoundsF = new RectangleF(0, 100, 550, 25),
};
// "mainReport" is an XtraReport instance.
// Add subreport to the main report's DetailBand.
mainReport.Bands["DetailBand"].Controls.Add(subreport);
// Reference a report from the report definition (REPX) file. The file is stored in the application's folder.
subreport.ReportSourceUrl = Path.Combine(Path.GetDirectoryName(typeof(ReportCreator).Assembly.Location), "DetailReport.repx");

The code sample below handles the XRSubreport.BeforePrint event to add an XRLabel control to the referenced report’s instance. This sample can be used with the code sample above.

using DevExpress.XtraReports.UI;
// ...
private void Subreport_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
    XRSubreport subreport = (XRSubreport)sender;
    XtraReport report = subreport.ReportSource;
    report.Bands["DetailBand"].Controls.Add(new XRLabel() {
        Text = " - ",
        BoundsF = new RectangleF(450, 0, 100, 25),
        Font = new Font(new FontFamily("Arial"), 9)
    });
}
See Also