Back to Devexpress

XRDesignMdiController.DesignPanelLoaded Event

xtrareports-devexpress-dot-xtrareports-dot-userdesigner-dot-xrdesignmdicontroller-bfee57a5.md

latest11.7 KB
Original Source

XRDesignMdiController.DesignPanelLoaded Event

Occurs when the End-User Designer loads a report and loads a new XRDesignPanel for that report.

Namespace : DevExpress.XtraReports.UserDesigner

Assembly : DevExpress.XtraReports.v25.2.Extensions.dll

NuGet Package : DevExpress.Win.Reporting

Declaration

csharp
public event DesignerLoadedEventHandler DesignPanelLoaded
vb
Public Event DesignPanelLoaded As DesignerLoadedEventHandler

Event Data

The DesignPanelLoaded event's data class is DesignerLoadedEventArgs. The following properties provide information specific to this event:

PropertyDescription
DesignerHostGets the designer host which provides all the services that are available for editing a report in its End-User Designer.

Remarks

Handle the DesignPanelLoaded event to customize the End-User Designer UI after a report is loaded. For code samples, review the following help topics:

The DesignPanelLoaded event in a multi-document interface is similar to the XtraReport.DesignerLoaded event that occurs in a single-document Report Designer version, but changes are applied to all reports opened within the End-User Report Designer form.

Example

This example illustrates how to add a custom control to an End-User Report Designer’s toolbox by handling the XRDesignMdiController.DesignPanelLoaded event and accessing the toolbox service.

Tip

This code adds the XRZipCode control to the toolbox. It is hidden by default because most countries do not use it.

See Use Custom Controls to learn how to create custom report controls and add them to a Report Designer’s toolbox.

csharp
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using System.Drawing.Design;
// ...

private void button1_Click(object sender, System.EventArgs e) {
    // Create a Design Tool with an assigned report instance.
    ReportDesignTool designTool = new ReportDesignTool(new XtraReport1());

    // Access the standard or ribbon-based Designer form.
    // IDesignForm designForm = designTool.DesignForm;
    IDesignForm designForm = designTool.DesignRibbonForm;

    // Handle the Design Panel's Loaded event.
    designForm.DesignMdiController.DesignPanelLoaded += DesignMdiController_DesignPanelLoaded;

    // Load a Report Designer in a dialog window.
    // designTool.ShowDesignerDialog();
    designTool.ShowRibbonDesignerDialog();
}

void DesignMdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) {
    // Access the Toolbox service.
    IToolboxService toolboxService =
        (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService));

    // Add a custom control to a new category.
    toolboxService.AddToolboxItem(new ToolboxItem(typeof(XRZipCode)), "New Category");

    // Add a custom control to the default category.
    // toolboxService.AddToolboxItem(new ToolboxItem(typeof(XRZipCode)));
}
vb
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.UserDesigner
Imports System.Drawing.Design
' ...

Private Sub button1_Click(sender As Object, e As System.EventArgs)
    ' Create a Design Tool with an assigned report instance.
    Dim designTool As New ReportDesignTool(New XtraReport1())

    ' Access the standard or ribbon-based Designer form.
    ' Dim designForm As IDesignForm = designTool.DesignForm
    Dim designForm As IDesignForm = designTool.DesignRibbonForm

    ' Handle the Design Panel's Loaded event.
    AddHandler designForm.DesignMdiController.DesignPanelLoaded, _ 
        AddressOf DesignMdiController_DesignPanelLoaded

    ' Load a Report Designer in a dialog window.
    ' designTool.ShowDesignerDialog()
    designTool.ShowRibbonDesignerDialog()
End Sub

Private Sub DesignMdiController_DesignPanelLoaded(sender As Object, e As DesignerLoadedEventArgs)
    ' Access the Toolbox service.
    Dim toolboxService As IToolboxService = _ 
        DirectCast(e.DesignerHost.GetService(GetType(IToolboxService)), IToolboxService)

    ' Add a custom control to a new category.
    toolboxService.AddToolboxItem(New ToolboxItem(GetType(XRZipCode)), "New Category")

    ' Add a custom control to the default category.
    ' toolboxService.AddToolboxItem(New ToolboxItem(GetType(XRZipCode)))
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the DesignPanelLoaded event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-winforms-designer-override-commands/CS/CustomSavingEUD/Form1.cs#L22

csharp
// to override the SaveCommandHandler for every loaded report.
mdiController.DesignPanelLoaded +=
    new DesignerLoadedEventHandler(mdiController_DesignPanelLoaded);

reporting-winforms-custom-progress-bar-control/CS/Form1.cs#L18

csharp
// Handle the DesignPanelLoaded event.
designForm.DesignMdiController.DesignPanelLoaded +=
    DesignMdiController_DesignPanelLoaded;

reporting-winforms-sql-data-source-runtime/CS/RuntimeSqlDataSourceReportSample/Form1.cs#L133

csharp
connectionProviderService);
designer.DesignRibbonForm.DesignMdiController.DesignPanelLoaded +=
    DesignMdiControllerOnDesignPanelLoaded;

reporting-winforms-wizard-data-connections/CS/T119350/Form1.cs#L30

csharp
typeof(IConnectionStorageService), connectionStorageService);
    this.reportDesigner1.DesignPanelLoaded += DesignMdiControllerOnDesignPanelLoaded;
}

reporting-winforms-custom-control-numeric-label/CS/Form1.cs#L22

csharp
IDesignForm designForm = designTool.DesignForm;
designForm.DesignMdiController.DesignPanelLoaded += DesignMdiController_DesignPanelLoaded;
designTool.ShowDesignerDialog();

reporting-winforms-designer-override-commands/VB/CustomSavingEUD/Form1.vb#L29

vb
' to override the SaveCommandHandler for every loaded report.
AddHandler mdiController.DesignPanelLoaded, AddressOf mdiController_DesignPanelLoaded

reporting-winforms-custom-progress-bar-control/VB/Form1.vb#L20

vb
' Handle the DesignPanelLoaded event.
AddHandler designForm.DesignMdiController.DesignPanelLoaded, AddressOf DesignMdiController_DesignPanelLoaded
' Load a report into the Designer.

reporting-winforms-sql-data-source-runtime/VB/RuntimeSqlDataSourceReportSample/Form1.vb#L115

vb
GetType(IConnectionProviderService), connectionProviderService)
AddHandler designer.DesignRibbonForm.DesignMdiController.DesignPanelLoaded,
    AddressOf DesignMdiControllerOnDesignPanelLoaded

reporting-winforms-wizard-data-connections/VB/T119350/Form1.vb#L26

vb
ReplaceService(Me.reportDesigner1, GetType(IConnectionStorageService), connectionStorageService)
    AddHandler Me.reportDesigner1.DesignPanelLoaded, AddressOf DesignMdiControllerOnDesignPanelLoaded
End Sub

reporting-winforms-custom-control-numeric-label/VB/Form1.vb#L24

vb
Dim designForm As IDesignForm = designTool.DesignForm
AddHandler designForm.DesignMdiController.DesignPanelLoaded, AddressOf DesignMdiController_DesignPanelLoaded
designTool.ShowDesigner()

See Also

Add a Custom Control to the End-User Report Designer Toolbox

XRDesignMdiController Class

XRDesignMdiController Members

DevExpress.XtraReports.UserDesigner Namespace