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 {
// ...
}
Public Class MyXtraReport
Inherits XtraReport
' ...
End Class
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();
}
}
Imports DevExpress.ExpressApp.ReportsV2
' ...
Public Class CustomReportStorage
Inherits ReportsStorage
Protected Overrides Function CreateReport() As XtraReport
Return New MyXtraReport()
End Function
End Class
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();
}
// ...
}
Imports DevExpress.ExpressApp.ReportsV2
' ...
Public NotInheritable Partial Class MySolutionModule
Inherits ModuleBase
Public Sub New()
' ...
ReportDataProvider.ReportsStorage = New CustomReportStorage()
End Sub
' ...
End Class
To check the result, run the application and create a report.