Back to Devexpress

ReportDesigner.RegisterControl<T>() Method

wpf-devexpress-dot-xpf-dot-reports-dot-userdesigner-dot-reportdesigner-dot-registercontrol-1.md

latest3.5 KB
Original Source

ReportDesigner.RegisterControl<T>() Method

Registers a custom control in the Report Designer and adds it to the Toolbox.

Namespace : DevExpress.Xpf.Reports.UserDesigner

Assembly : DevExpress.Xpf.ReportDesigner.v25.2.dll

NuGet Package : DevExpress.Wpf.Reporting

Declaration

csharp
public static void RegisterControl<T>()
    where T : XRControl, new()
vb
Public Shared Sub RegisterControl(Of T As {XRControl, New})

Type Parameters

NameDescription
T

The control’s type.

|

Remarks

The following example registers a custom control in the Report Designer. This control appears in the Toolbox.

csharp
using DevExpress.Xpf.Reports.UserDesigner;
using DevExpress.XtraReports.UI;
using System.Windows;
//...

public class ProgressBar : XRControl { /* ... */ }
//...

public partial class MainWindow : Window {
    public MainWindow() {
        InitializeComponent();
        ReportDesigner.RegisterControl<ProgressBar>();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e) {
        reportDesigner.OpenDocument(new XtraReport());
    }
}
vb
Imports DevExpress.Xpf.Reports.UserDesigner
Imports DevExpress.XtraReports.UI
Imports System.Windows
'...

Public Class ProgressBar ' ...
    Inherits XRControl

End Class
'...

Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()
        ReportDesigner.RegisterControl(Of ProgressBar)()
    End Sub

    Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        reportDesigner.OpenDocument(New XtraReport())
    End Sub
End Class

A custom control inherits an icon from a base class. If the base class does not have an icon (e.g., XRControl ), the control inherits the default icon (a gear).

You can change the default icon. Use one of the following techniques:

  • Call the RegisterControl<T>(ImageSource) method instead of the RegisterControl<T>() method to set a custom ImageSource icon.
  • Apply the ToolboxSvgImage attribute to the custom control class and call the RegisterControl<T>() method to set an icon from an assembly.

Tip

To unregister a control and remove it from the Toolbox , use the UnregisterControl<T>() method.

See Also

ReportDesigner Class

ReportDesigner Members

DevExpress.Xpf.Reports.UserDesigner Namespace