Create an Inherited Report

This tutorial describes how to make a newly created report inherit its settings from an existing XtraReport at design time within 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

The visual inheritance of reports is similar to that of Windows Forms. It allows you to create a base report, and then inherit from it and make modifications in descendant reports, while preserving the layout and settings of the original report. To learn more about visual inheritance, refer to the following MSDN article: Windows Forms Visual Inheritance.

To create a parent report, whose layout will be inherited by all descendants, do the following:

  1. Define a layout for the default parent report. For example, create a simple static report by adding an XRLabel to its detail band. All future reports should inherit this basic 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. To learn more about access modifiers in .NET, see the following topics in MSDN: 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 v18.1 Report Wizard item.

    add-a-new-report-winforms-report-wizard

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

    xtrareport-wizard-inherited-report-page-01

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

    how-to-create-an-inherited-report-0

    Alternatively, you can select the ancestor report that is contained in a separate assembly. To do this, click Select the assembly that contains ancestor reports and, in the invoked Open Assembly dialog, select the required assembly.

    how-to-create-an-inherited-report-1

Editing of the created inherited report will be prohibited unless this is allowed by the Modifiers property setting of the ancestor report.

Customize the Inherited Report

After adding the inherited report, you can add new elements to it (bands and controls), and modify the inherited elements that were made public.

inheritedReport5

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

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

inheritedReport6