SubreportBase.ReportSource Property
Gets or sets an XtraReport class instance. This instance’s content is included in the main report.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
#Declaration
[SRCategory(ReportStringId.CatData)]
public XtraReport ReportSource { get; set; }
#Property Value
Type | Description |
---|---|
Xtra |
An Xtra |
#Remarks
Rebuild the solution at design time after you declare an XtraReport class to be able to reference this class in the XRSubreport‘s ReportSource property.
The ReportSource
property can only access XtraReport instances, it cannot accept REPX
files. In the Report Designer, the ReportSource
property drop-down list displays a list of report classes defined in your application (rebuild the app so that all classes are available).
Note
The Report
Use the ReportSourceUrl property instead of ReportSource to reference a report that is stored in a report definition (REPX) or XML file.
The ReportSourceUrl property value takes precedence over the ReportSource value. If you specify both properties, the XRSubreport includes the content from the report specified by ReportSourceUrl.
See XRSubreport for more information.
#Examples
The code sample below adds an XRSubreport item to the report and uses the ReportSource
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 an XtraReport instance named "detailReport" to include its content into the main report.
subreport.ReportSource = detailReport;
The following code snippet handles the XRSubreport.BeforePrint event to add an XRLabel control to the referenced report’s instance.
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)
});
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ReportSource property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.