Back to Devexpress

DiagramControl.CustomGetEditableItemProperties Event

windowsforms-devexpress-dot-xtradiagram-dot-diagramcontrol-89444214.md

latest3.5 KB
Original Source

DiagramControl.CustomGetEditableItemProperties Event

Allows you to modify the list of diagram item properties that can be edited by end-users in the Properties Panel.

Namespace : DevExpress.XtraDiagram

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

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

Event Data

The CustomGetEditableItemProperties event's data class is DevExpress.XtraDiagram.DiagramCustomGetEditableItemPropertiesEventArgs.

Remarks

The event’s Properties member provides access to the collection of editable item properties.

See the example below.

csharp
private void diagramControl_CustomGetEditableItemProperties(object sender, DiagramCustomGetEditableItemPropertiesEventArgs e) {
    if (e.Item is DiagramShapeEx) {
        e.Properties.Add(TypeDescriptor.GetProperties(typeof(DiagramShapeEx))["Description"]);
    }
}
vb
Private Sub diagramControl_CustomGetEditableItemProperties(ByVal sender As Object, ByVal e As DiagramCustomGetEditableItemPropertiesEventArgs)
    If TypeOf e.Item Is DiagramShapeEx Then
        e.Properties.Add(TypeDescriptor.GetProperties(GetType(DiagramShapeEx))("Description"))
    End If
End Sub

The event’s CreateProxyProperty method allows you to edit the object that is the item’s DataContext. See the example below.

csharp
//DiagramShape shape = new DiagramShape() { DataContext = new Customer() { ID = 1, Name = "Test" } };
private void DiagramControl1_CustomGetEditableItemProperties(object sender, DiagramCustomGetEditableItemPropertiesEventArgs e) {
    if (e.Item is DiagramShape)
        e.Properties.Add(e.CreateProxyProperty("Name", item => ((Customer)item.DataContext).Name, (item, value) => ((Customer)item.DataContext).Name = value));
}
vb
'Dim shape As New DiagramShape() With {
' .DataContext = New Customer() With {
' .ID = 1,
' .Name = "Test"
' }
'}
Private Sub DiagramControl1_CustomGetEditableItemProperties(ByVal sender As Object, ByVal e As DiagramCustomGetEditableItemPropertiesEventArgs)
    If TypeOf e.Item Is DiagramShape Then
        e.Properties.Add(e.CreateProxyProperty("Name", Function(item) CType(item.DataContext, Customer).Name, Function(item, value) CType(item.DataContext, Customer).Name = value))
    End If
End Sub

See Also

CustomGetEditableItemPropertiesCacheKey

DiagramControl Class

DiagramControl Members

DevExpress.XtraDiagram Namespace