Skip to main content

Remove Data Source Types from the Report Wizard

  • 2 minutes to read

This example illustrates how to remove certain of the data source types available on the Select the Data Source Type wizard page.

The following image illustrates this wizard page with the Excel File and Object Binding options removed.

report-wizard-select-data-source-type-customize-remove

To customize the Data Source and Report wizard pages, do the following.

  1. Add a custom service implementing the IWizardCustomizationService interface.

    using DevExpress.DataAccess.UI.Wizard;
    using DevExpress.DataAccess.Wizard.Model;
    using DevExpress.DataAccess.Wizard.Services;
    using DevExpress.XtraReports.Wizards;
    using System.ComponentModel.Design;
    // ...
    
    class WizardCustomizationService : IWizardCustomizationService {
        void IWizardCustomizationService.CustomizeReportWizard(IWizardCustomization<XtraReportModel> tool) {
            DataSourceTypes dataSourceTypes = tool.Resolve(typeof(DataSourceTypes)) as DataSourceTypes;
            dataSourceTypes.Remove(DataSourceType.Excel);
            dataSourceTypes.Remove(DataSourceType.Object);
        }
    
        void IWizardCustomizationService.CustomizeDataSourceWizard(IWizardCustomization<XtraReportModel> tool) {
            DataSourceTypes dataSourceTypes = tool.Resolve(typeof(DataSourceTypes)) as DataSourceTypes;
            dataSourceTypes.Remove(DataSourceType.Excel);
            dataSourceTypes.Remove(DataSourceType.Object);
        }
    
        bool IWizardCustomizationService.TryCreateDataSource(IDataSourceModel model, out object dataSource, out string dataMember) {
            dataSource = null;
            dataMember = null;
            return false;
        }
    
        bool IWizardCustomizationService.TryCreateReport(IDesignerHost designerHost, XtraReportModel model, object dataSource, string dataMember) {
            return false;
        }
    }
    
  2. Register the created service by calling the XRDesignMdiController.AddService method.

    using DevExpress.XtraReports.Wizards;
    // ...
    
    namespace WindowsFormsApplication1 {
        public partial class Form1 : System.Windows.Forms.Form {
            public Form1() {
                InitializeComponent();
                reportDesigner1.AddService(typeof(IWizardCustomizationService), new WizardCustomizationService());
                Load += Form1_Load;
            }
    
            void Form1_Load(object sender, System.EventArgs e) {
                reportDesigner1.CreateNewReportWizard();
            }
        }
    }
    
See Also