Skip to main content
.NET 6.0+

WinReportServiceController.CreateCustomDesignForm Event

Occurs when the Report Designer form is created.

Namespace: DevExpress.ExpressApp.ReportsV2.Win

Assembly: DevExpress.ExpressApp.ReportsV2.Win.v24.1.dll

Declaration

public event EventHandler<CreateCustomDesignFormEventArgs> CreateCustomDesignForm

Event Data

The CreateCustomDesignForm event's data class is DevExpress.ExpressApp.ReportsV2.Win.CreateCustomDesignFormEventArgs.

Remarks

Handle this event to specify a custom Report Designer form. In the event handler, pass your custom form to the DesignForm parameter. An example is provided in the How to: Use the Custom WinForms Report Designer topic.

You can also use the CreateCustomDesignForm event to customize the default Report Designer. For instance, you can add a custom Data Source component (inherited from DataSourceBase) to the designer’s toolbox:

using DevExpress.ExpressApp.ReportsV2.Win;
// ...
public class AddCustomDataSourceController : ViewController {
    private WinReportServiceController reportService;
    protected override void OnActivated() {
        base.OnActivated();
        reportService = Frame.GetController<WinReportServiceController>();
        if (reportService != null) {
             reportService.CreateCustomDesignForm += delegate(object sender, CreateCustomDesignFormEventArgs e) {
                e.DesignForm.DesignMdiController.DesignPanelLoaded += DesignMdiController_DesignPanelLoaded;
                ((XtraForm)designForm).FormClosed += designForm_FormClosed;
            };
        }
    }
    private void DesignMdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs args) {
        AddToolboxItem(args.DesignerHost);
    }
    private void AddToolboxItem(IServiceProvider serviceProvider) {
        IToolboxService ts = (IToolboxService)serviceProvider.GetService(typeof(IToolboxService));
        ts.AddToolboxItem(new ToolboxItem(typeof(CustomDataSource)), "Custom Category");
    }
    private void designForm_FormClosed(object sender, FormClosedEventArgs e) {
        ((IDesignForm)sender).DesignMdiController.DesignPanelLoaded -= new DesignerLoadedEventHandler(DesignMdiController_DesignPanelLoaded);
        ((XtraForm)sender).FormClosed -= new FormClosedEventHandler(designForm_FormClosed);
    }
}
See Also