Skip to main content

Customize the Report Wizard Pages

  • 5 minutes to read

This document describes how to add a custom page to the Report wizard.

View Example: How to customize the Report Wizard in the End-User Designer

Create a Custom Report Wizard Page

A wizard page definition consists of a View and a Presenter. The View defines the page visual interface. The Presenter determines the program logic behind the wizard page. To create a custom wizard page, you should implement the following classes:

Page View Class
Page View class is an DevExpress.XtraEditors.XtraUserControl descendant populated with data editors. A custom page view class should descend from the WizardViewBase class that implements the DevExpress.DataAccess.Wizard.Views.IWizardPageView interface. A page view class should also implement a specific interface required to associate a presenter with a page view. These interfaces are contained in the DevExpress.DataAccess.Wizard.Views namespace.
Presenter Class
Inherits from the base WizardPageBase<TView, TModel> class or from the existing wizard presenters.

You can choose a proper page and a presenter, and create descendants for your custom page. The following help topics describe page views and presenters available in the Data Source and Report Wizards:

A 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.

The following code implements the service that registers custom presenters (ChoosePersonsPage,ChoosePersonsPage2,ChoosePersonsPage3) and a wizard page view (ChoosePersonsPageView2). The ChoosePersonsPageView2 class implements the custom IChoosePersonsPageView interface that inherits the DevExpress.DataAccess.Wizard.Views.IChooseDataSourceTypePageView interface.

using System.ComponentModel.Design;
using DevExpress.DataAccess.UI.Wizard;
using DevExpress.DataAccess.Wizard.Model;
using DevExpress.XtraReports.Wizards;
using DevExpress.XtraReports.Wizards.Presenters;

class WizardCustomizationService : IWizardCustomizationService
    void IWizardCustomizationService.CustomizeDataSourceWizard(IWizardCustomization<XtraReportModel> tool)
        // Sets the start page.
        tool.StartPage = typeof(Presenters.ChoosePersonsPage2<DataSourceModel>);
        // Registers the custom presenter.
        // Registers the custom page view.
    void IWizardCustomizationService.CustomizeReportWizard(IWizardCustomization<XtraReportModel> tool)
        // Redefines the start page.
        // Register the custom presenter.
        // Register the custom page view.
    bool IWizardCustomizationService.TryCreateReport(IDesignerHost designerHost,
        XtraReportModel model, object dataSource, string dataMember)
        return false;
    bool IWizardCustomizationService.TryCreateDataSource(IDataSourceModel model,
        out object dataSource, out string dataMember)
        // ...
        // if failed to create a data source:
        dataMember = string.Empty;
        dataSource = null;
        return false;

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);
See Also