A newer version of this page is available. Switch to the current version.

XRSubreport Class

A Subreport control that is used to embed other reports in an XtraReport.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll


public class XRSubreport :
Public Class XRSubreport
    Inherits SubreportBase


By placing an XRSubreport instance onto your report, you can embed other reports into it (via the SubreportBase.ReportSource property), e.g. to create master-detail reports, side-by-side reports or prepare templates for reusing reports or their parts (headers or footers).

Within an MDI End-User Report Designer, if an end-user double-clicks an XRSubreport control, the report assigned to it is opened in a new Design Panel of the current Designer form.


This example illustrates the use of the XRSubreport control at runtime.

Not that at runtime, you can also assign a subreport by handling the XRControl.BeforePrint event of the XRSubreport control and setting its SubreportBase.ReportSource property.

using DevExpress.XtraReports.UI;
// ...

private void xrSubreport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
    ((XRSubreport)sender).ReportSource = new WindowsFormsApplication1.Reports.XtraReport3();

The following example demonstrates how to create a XRSubreport control and adjust some of its main properties (e.g. SubreportBase.ReportSource). This example assumes that an XtraReport object passed as a parameter to the CreateCompositeReport method, has already been created in the current project.

using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

public XtraReport CreateCompositeReport(XtraReport detailReport) {
    // Create a report.
    XtraReport mainReport = new XtraReport();

    // Create a subreport.
    XRSubreport subreport = new XRSubreport();

    // Create a detail band and add it to the main report.
    DetailBand detailBand = new DetailBand();

    // Set the subreport's location.
    subreport.Location = new Point(110, 100);

    // Specify a detail report as a report source for the subreport.
    subreport.ReportSource = detailReport;

    // Add the subreport to the detail band.

    return mainReport;


See Also