Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Remove Data Providers from the Report Wizard

  • 3 minutes to read

This topic describes how to customize the list of data providers on the Specify Connection Properties wizard page (for instance, display the Microsoft SQL Server option only).

wpf-report-wizard-removing-data-providers

Use one of the following techniques to remove data providers from the Report Wizard.

#Removing Data Providers at Design Time

You can customize various Data Source and Report Wizard options at design time using the ReportDesignerBase.DataSourceWizardSettings property. The SqlWizardSettings.AvailableDataProviders property allows you to select which data providers are displayed on the Specify Connection Properties page.

The following XAML code demonstrates how to specify this setting:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" 
        xmlns:dxda="http://schemas.devexpress.com/winfx/2008/xaml/dataaccess"
        Title="MainWindow" >
    <dxrud:ReportDesigner DataSourceWizardSettings="{dxda:DataSourceWizardSettings 
            SqlWizardSettings={dxda:SqlWizardSettings AvailableDataProviders=MSSqlServer}}">
    </dxrud:ReportDesigner>
</Window>

#Removing Data Providers at Runtime

Do the following to customize the list of data providers at runtime and make the Specify Connection Properties page the Wizard’s first page:

  1. Implement the IWizardCustomizationService interface and define the required customization logic in its methods. Remove the Select the Data Source Type page by enabling only the DataSourceType.Xpo setting (corresponding to the Database connection option).

    using DevExpress.DataAccess.Native.Sql.ConnectionStrategies;
    using DevExpress.DataAccess.Wizard.Model;
    using DevExpress.DataAccess.Wizard.Presenters;
    using DevExpress.Utils.IoC;
    using DevExpress.Xpf.DataAccess.DataSourceWizard;
    using DevExpress.Xpf.Reports.UserDesigner.ReportWizard;
    using DevExpress.Xpf.Reports.UserDesigner.ReportWizard.Pages;
    using DevExpress.XtraReports.UI;
    using DevExpress.XtraReports.Wizards;
    using System.Collections.Generic;
    // ...
    
    namespace WpfApplication1 {
        public class MyWizardCustomizationService : IWizardCustomizationService {
            void IDataSourceWizardCustomizationService.CustomizeDataSourceWizard(DataSourceWizardCustomizationModel customization, 
                ViewModelSourceIntegrityContainer container) {
                if (customization.StartPage == typeof(ChooseDataSourceTypePage<IDataSourceModel>)) {
                    customization.Model.DataSourceType = DataSourceType.Xpo;
                    customization.StartPage = typeof(ConnectionPropertiesPage<IDataSourceModel>);
                }
                CustomizeProviders(container);
            }
    
            void IWizardCustomizationService.CustomizeReportWizard(ReportWizardCustomizationModel customization, 
                ViewModelSourceIntegrityContainer container) {
                if (customization.StartPage == typeof(ChooseReportTypePage)) {
                    customization.Model.ReportType = ReportType.Standard;
                    customization.Model.DataSourceType = DataSourceType.Xpo;
                    customization.StartPage = typeof(ConnectionPropertiesPage<IDataSourceModel>);
                }
                CustomizeProviders(container);
            }
    
            bool IDataSourceWizardCustomizationService.TryCreateDataSource(IDataSourceModel model, 
                out object dataSource, out string dataMember) {
                dataSource = null;
                dataMember = null;
                return false;
            }
    
            bool IWizardCustomizationService.TryCreateReport(XtraReportModel model, out XtraReport report) {
                report = null;
                return false;
            }
    
            static void CustomizeProviders(IntegrityContainer container) {
                var providers = container.Resolve<List<ProviderLookupItem>>();
                providers.RemoveAll((ProviderLookupItem x) => x.ProviderKey != "MSSqlServer");
            }
        }
    }
    
  2. To apply the changes, assign your custom IWizardCustomizationService implementation to the ReportDesignerBase.ServicesRegistry property as follows:

    <dxrud:ReportDesigner x:Name="reportDesigner">
        <dxrud:ReportDesigner.ServicesRegistry>
            <dxda:TypeEntry ServiceType="{x:Type dxrudw:IWizardCustomizationService}" ConcreteType="{x:Type local:MyWizardCustomizationService}" />
        </dxrud:ReportDesigner.ServicesRegistry>
    </dxrud:ReportDesigner>
    
See Also