Skip to main content

Create an Inherited Report

  • 4 minutes to read

This tutorial describes how to make a newly created report inherit its settings from an existing XtraReport at design time in Visual Studio.

Create a Reporting Application

Create a reporting application. To learn how to create a reporting application on the platform of your choice, see Adding a Report to Your .NET Application.

Although this tutorial is based on Windows Forms, the same steps apply for inheriting reports on any other supported platform.

Create a Base Report

Visual report inheritance is similar to Windows Forms visual inheritance. It allows you to create a base report and then inherit from it in descendant reports while preserving the original report’s layout and settings. For more information, see Windows Forms Visual Inheritance.

To create a parent report whose layout is inherited by all descendant reports, do the following:

  1. Define a layout for the default parent report. For example, create a simple static report by adding an XRLabel to the Detail band. All descendant reports inherit this base layout.

    The label created in the base report will be available in all inherited reports. To permit changes in an individual label’s properties (independent of the base report), set the control’s Modifiers property to Protected, Protected Internal or Public.

    inheritedReport2

    The exact setting of the Modifiers property depends on your application requirements. TFor more information about access modifiers in .NET, review the following topics: Access Modifiers (C# Programming Guide) and Access Levels in Visual Basic.

    Set this property for every object that you wish to modify in inherited reports.

  2. Before proceeding with the following steps, rebuild your application by clicking BUILD | Rebuild Solution in the main menu in Visual Studio. This will generate the application’s assembly (.exe or .dll) file containing the base report class, and the inherited reports will gain access to the base report at design time.

    Shared_RebuildSolution

Create an Inherited Report

To add a new inherited report to an application, do the following.

  1. In Visual Studio, press CTRL+SHIFT+A or click PROJECT | Add New Item… in the main menu.
  2. In the Add New Item dialog that is invoked, switch to the Reporting directory and select DevExpress v26.1 Report item.

    Add New Item to a Report

  3. Next, in the invoked Report Wizard, choose Inherited Report and click Next.

    Report Wizard - Choose Inherited Report

  4. On the next wizard page, select an ancestor report from the list of available reports and click Finish. The new report then inherits its layout from the selected report.

    Report Wizard - Select Ancestor Report

    Alternatively, you can select an ancestor report from a separate assembly. To do this, click Select the assembly that contains ancestor reports and choose the assembly in the Open Assembly dialog.

    Report Wizard - Select Ancestor Report from Assembly

Editing the created inherited report is not allowed unless the ancestor report’s Modifiers property permits it.

Create an Inherited Report in .NET Applications

In .NET projects, the Report Wizard does not have the Inherited Report option. To create an inherited report, create a report class in code and derive it from a base report class.

The base report must define a public constructor with the InitializeComponent method. If you make any layout changes for the inherited report, the report designer generates the InitializeComponent method for the inherited report. The inherited report has to define a public constructor with the InitializeComponent method as well.

Base Report:

public class BaseReport : XtraReport {
    public BaseReport() {
        InitializeComponent();
    }
}

Inherited Report:

public class InheritedReport : BaseReport {
    public InheritedReport(){
        InitializeComponent()
    }
    // ...
}

Customize the Inherited Report

After you add the inherited report, you can add new elements, such as bands and controls, and modify publicly available inherited elements.

Inherited Report

When you change the property values of inherited controls, these properties are overridden in the inherited report.

To obtain a property value from the base report, reset the property. To do this, select the control, locate the required property in the Properties window (for example, ForeColor), right-click the property, and select Reset.

Inherited Report - Reset Property

Limitations

  • You cannot localize properties of Inherited Reports.