Skip to main content

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.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

[DefaultValue("")]
[SRCategory(ReportStringId.CatData)]
public string ReportSourceUrl { get; set; }

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 “~” character). The relative (~) path is relative to the root directory specified by the StorageOptions.RootDirectory property.

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

The ReportSourceUrl property takes precedence over the ReportSource property. If you specify both properties, the XRSubreport includes the content from the report specified by the ReportSourceUrl property.

The ReportSource property can only access XtraReport descendant class instances; it cannot accept REPX files or paths. Thus, the ReportSource property editor’s drop-down list in the designer shows a list of XtraReport classes in your application. If this drop-down list is empty, the Report Designer cannot find XtraReport classes in the application. You should add XtraReport classes or rebuild the application. For information on how to add XtraReport classes to your application, review the following help topic: Create a Report in Visual Studio.

The ReportSourceUrl property allows you to specify a path to the REPX report file. However, you can implement a custom report storage in the WinForms application that translates report string identifiers to the XtraReport instances. In the custom storage class, you can implement the ReportStorageExtension.GetStandardUrls method, which populates the ReportSourceUrl property editor with report identifiers.

When the main report is rendered, the report referenced in the ReportSourceUrl property is instantiated. The XtraReport instance is assigned to the ReportSource property. You can handle the XRSubreport.BeforePrint event and access the subreport instance using the ReportSource property in the event handler.

Examples

Add Subreport to DetailBand

The following code snippet adds an XRSubreport control to the report and uses the ReportSourceUrl property to reference a detail report.

View 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");

Handle BeforePrint Event to Get Access to Subreport

The following code snippet handles the XRSubreport.BeforePrint event to add an XRLabel control to the referenced report 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)
    });
}
See Also