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.
在某些情况下,您可能需要自定义基本报表类,以提供所有新报表中可用的自定义功能。本主题介绍如何注册自定义 XtraReport 后代,该后代将在最终用户在运行时创建报表时使用。
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.
执行以下操作,在新的用户定义的报表中使用 MyXtraReport 而不是 XtraReport。
-
在模块项目中,继承报表存储类并重写创建报表方法。
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.
要检查结果,请运行应用程序并创建报表。