Skip to main content

DiagramControl.ItemCreating Event

Occurs when the DiagramControl creates a diagram item.

Namespace: DevExpress.XtraDiagram

Assembly: DevExpress.XtraDiagram.v24.2.dll

Declaration

[DiagramCategory(DiagramCategory.DiagramItems)]
public event EventHandler<DiagramItemCreatingEventArgs> ItemCreating

Event Data

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

Property Description
Item Gets or sets the item that is about to be created.
ItemType Gets the type of the item that is about to be created.
ItemUsage Indicates 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.

private void DiagramControl1_ItemCreating(object sender, DevExpress.XtraDiagram.DiagramItemCreatingEventArgs e) {
    if (e.ItemType == typeof(DiagramShape)) {
        e.Item = new DiagramShapeEx();
    }
}

Tip

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

DiagramControl.ItemTypeRegistrator.Register(typeof(DiagramShapeEx));
See Also