Customize the Report Wizard Pages
- 3 minutes to read
This document describes how to add a custom page to a Report wizard.
Tip
Online Example: How to customize the Report Wizard in the End-User Designer
Create a Custom Report Wizard Page
Each wizard page is defined by a Wizard Page View determining the page’s visual interface and a Wizard Page Presenter determining the program logic behind the wizard page. To create a custom wizard page, do one of the following.
- Create a custom page from scratch by inheriting from the WizardViewBase and WizardPageBase<TView, TModel> classes to implement a page view and presenter respectively. Typically, a page view is an XtraUserControl descendant.
Customize an existing wizard page by inheriting from its presenter and (optionally) view objects.
The following documents list the default page views and presenters used in the Data Source and Report wizards.
Each page presenter should override the WizardPageBase<TView,TModel>.GetNextPageType method that returns the type of the subsequent wizard page and defines the order in which wizard pages are displayed.
public override Type GetNextPageType() {
return (View.ReportType == ReportType.Standard)
? typeof(ChoosePersonsPage2<XtraReportModel>)
: base.GetNextPageType();
}
Incorporate a Custom Page Into the Report Wizard
To customize the Report and/or Data Source wizard, implement the IWizardCustomizationService interface. The wizard customization logic should be written in the body of the IWizardCustomizationService.CustomizeDataSourceWizard method (to customize the Data Source wizard) and the IWizardCustomizationService.CustomizeReportWizard method (to customize the Report wizard). Both these methods receive a tool argument of the IWizardCustomization<TModel> type providing access to the IWizardCustomization<TModel>.StartPage property that allows you to specify the first wizard page.
Each page presenter and page view should be registered by calling the IWizardCustomization<TModel>.RegisterPage<TPageType, TPageInstance> and IWizardCustomization<TModel>.RegisterPageView<TViewType, TViewInstance> methods respectively.
void IWizardCustomizationService.CustomizeDataSourceWizard(IWizardCustomization<DataSourceModel> tool) {
// Specify the start page.
tool.StartPage = typeof(ChoosePersonsPage2<DataSourceModel>);
// Register the custom page.
tool.RegisterPage<ChoosePersonsPage2<DataSourceModel>, ChoosePersonsPage2<DataSourceModel>>();
// Register the custom page view.
tool.RegisterPageView<IChoosePersonsPageView, ChoosePersonsPageView2>();
}
void IWizardCustomizationService.CustomizeReportWizard(IWizardCustomization<XtraReportModel> tool) {
// Redefine the start page.
tool.RegisterPage<ChooseReportTypePageEx<XtraReportModel>, ChoosePersonsPage>();
// Register the custom page.
tool.RegisterPage<ChoosePersonsPage2<XtraReportModel>, ChoosePersonsPage3>();
// Register the custom page view.
tool.RegisterPageView<IChoosePersonsPageView, ChoosePersonsPageView2>();
}
The RegisterPage method associates the type that identifies the page within the wizard (the type that should be returned by the GetNextPageType method of the previous page) with the actual type of the page that should be displayed. In the same way, the RegisterPageView method associates the type identifying the page view (the corresponding presenter’s type parameter) with the actual type. This allows you to substitute any standard wizard page with its descendant. The code sample below demonstrates how to substitute the query customization page with a custom page.
public void CustomizeDataSourceWizard(IWizardCustomization<DataSourceModel> tool) {
tool.RegisterPage<ConfigureQueryPage<TModel>, MyConfigureQueryPage<TModel>>();
tool.RegisterPageView<IConfigureQueryPageView, MyConfigureQueryPageView>();
}
Register the Wizard Customization Extension
To apply your wizard customization logic to the End-User Report Designer for WinForms, pass an instance of your IWizardCustomizationSevice implemetation to the report designer’s XRDesignMdiController.AddService method as shown below.
reportDesignerMDIController.AddService(typeof(IWizardCustomizationService), customizationService);