Back to Devexpress

XRDesignPanel.DesignerHostLoaded Event

xtrareports-devexpress-dot-xtrareports-dot-userdesigner-dot-xrdesignpanel-af565013.md

latest4.6 KB
Original Source

XRDesignPanel.DesignerHostLoaded Event

Occurs after the designer host is activated for a report currently being edited in the current Design Panel.

Namespace : DevExpress.XtraReports.UserDesigner

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

NuGet Package : DevExpress.Win.Reporting

Declaration

csharp
public event DesignerLoadedEventHandler DesignerHostLoaded
vb
Public Event DesignerHostLoaded As DesignerLoadedEventHandler

Event Data

The DesignerHostLoaded 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

Use the DesignerHostLoaded event, to perform particular actions (for instance, customize the designer’s Toolbox), after all initialization has been performed (all the hosts and services required by the End-User Designer have been initialized) and the Designer is ready to be shown.

Example

This example adds a custom control to the toolbox in the End-User Report Designer for Winforms. The XtraReport.DesignerLoaded event is used to access 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) {
    XtraReport1 report = new XtraReport1();
    ReportDesignTool designTool = new ReportDesignTool(report);
    report.DesignerLoaded += report_DesignerLoaded;
    designTool.ShowRibbonDesignerDialog();
}

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

    // Add a custom control to the default category.
    toolboxService.AddToolboxItem(new ToolboxItem(typeof(XRZipCode)));

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

Private Sub button1_Click(sender As Object, e As System.EventArgs)
    Dim report As New XtraReport1()
    Dim designTool As New ReportDesignTool(report)
    AddHandler report.DesignerLoaded, AddressOf report_DesignerLoaded
    designTool.ShowRibbonDesignerDialog()
End Sub

Private Sub report_DesignerLoaded(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 the default category.
    toolboxService.AddToolboxItem(New ToolboxItem(GetType(XRZipCode)))

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

See Also

API and Customization

XRDesignPanel Class

XRDesignPanel Members

DevExpress.XtraReports.UserDesigner Namespace