Back to Devexpress

DiagramControl.ItemCreating Event

windowsforms-devexpress-dot-xtradiagram-dot-diagramcontrol-2bb80a47.md

latest2.9 KB
Original Source

DiagramControl.ItemCreating Event

Occurs when the DiagramControl creates a diagram item.

Namespace : DevExpress.XtraDiagram

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

csharp
[DiagramCategory(DiagramCategory.DiagramItems)]
public event EventHandler<DiagramItemCreatingEventArgs> ItemCreating
vb
<DiagramCategory(DiagramCategory.DiagramItems)>
Public Event ItemCreating As EventHandler(Of DiagramItemCreatingEventArgs)

Event Data

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

PropertyDescription
ItemGets or sets the item that is about to be created.
ItemTypeGets the type of the item that is about to be created.
ItemUsageIndicates whether the item is a part of the diagram or toolbox preview.

Remarks

You can use the ItemCreating event to create custom items. The following code snippet illustrates how to use the event to substitute regular shapes with custom DiagramShapeEx shapes.

csharp
private void DiagramControl1_ItemCreating(object sender, DevExpress.XtraDiagram.DiagramItemCreatingEventArgs e) {
    if (e.ItemType == typeof(DiagramShape)) {
        e.Item = new DiagramShapeEx();
    }
}
vb
Private Sub DiagramControl1_ItemCreating(ByVal sender As Object, ByVal e As DevExpress.XtraDiagram.DiagramItemCreatingEventArgs)
    If e.ItemType Is GetType(DiagramShape) Then
        e.Item = New DiagramShapeEx()
    End If
End Sub

Tip

Register custom item types at the application start using the DiagramItemTypeRegistrator.Register method to enable their deserialization.

csharp
DiagramControl.ItemTypeRegistrator.Register(typeof(DiagramShapeEx));
vb
DiagramControl.ItemTypeRegistrator.Register(GetType(DiagramShapeEx))

See Also

DiagramControl Class

DiagramControl Members

DevExpress.XtraDiagram Namespace