XRSubreport.ReportSourceUrl Property

Gets or sets a URL or path that specifies a report's location. The report content is included in the main report.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v20.2.dll

Declaration

[DefaultValue("")]
[SRCategory(ReportStringId.CatData)]
public string ReportSourceUrl { get; set; }
<DefaultValue("")>
<SRCategory(ReportStringId.CatData)>
Public Property ReportSourceUrl As String

Property Value

Type Default Description
String

String.Empty

A URL or path that specifies a report's location.

Remarks

Specify the URL or path to a REPX or XML file in the XRSubreport control's ReportSourceUrl property to reference a report the content from which should be included in the main report in place of the XRSubreport.

NOTE

The ReportSourceUrl property is not available in Visual Studio Report Designer.
In Web Report Designer, implement a report storage to allow users to specify the Report Source Url property.
Additionally, in ASP.NET Core web applications, use the Bind() method to specify the main report.

You can specify an absolute or relative path (starting with a "~").

To reference an XtraReport class instance, use the XRSubreport's ReportSource property instead of ReportSourceUrl.

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.

The layout of the report referenced in the ReportSourceUrl property is instantiated as an XtraReport object when the main report is rendered. The XtraReport object is assigned to the XRSubreport's ReportSource property. You can handle the XRSubreport.BeforePrint event to access the referenced report object through the ReportSource property.

See XRSubreport for more information.

Examples

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 a 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.Drawing.Printing.PrintEventArgs 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