The requested page is not available for the requested platform. You are viewing the content for Default platform.

How to: Use a Custom XtraReport Descendant as the Base Class for New Reports

  • 2 min to read

In certain scenarios you may want to customize the base reports class to provide custom functionality available in all new reports. This topic describes how you can register a custom XtraReport descendant that will be used when an end-user creates a report at runtime.

Assume you have the following custom report class.

public class MyXtraReport : XtraReport {
   // ...
 }

Do the following to use MyXtraReport instead of XtraReport in new user-defined reports.

  • In the module project, inherit the ReportsStorage class and override the CreateReport method.

    using DevExpress.ExpressApp.ReportsV2;
    // ...
    public class CustomReportStorage : ReportsStorage {
        protected override XtraReport CreateReport() {
            return new MyXtraReport();
        }
    }
    
  • In the module's constructor, assign an instance of your ReportsStorage descendant to the static ReportDataProvider.ReportsStorage property.

    using DevExpress.ExpressApp.ReportsV2;
    // ...
    public sealed partial class MySolutionModule : ModuleBase {
        public MySolutionModule() {
            // ...
            ReportDataProvider.ReportsStorage = new CustomReportStorage();
        }
        // ...
    }
    

To check the result, run the application and create a report.

 XtraReport_Descendant