Back to Devexpress

DiagramControl.CustomGetEditableItemPropertiesCacheKey Event

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

latest3.9 KB
Original Source

DiagramControl.CustomGetEditableItemPropertiesCacheKey Event

Allows you to update the set of properties displayed by the property grid.

Namespace : DevExpress.XtraDiagram

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

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

Event Data

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

PropertyDescription
CacheKeyGets or sets the cache key assigned to the edited diagram item.
ItemReturns the edited diagram item.

Remarks

The DiagramControl caches a set of editable properties for each diagram item type. These properties are displayed by the property grid when an end-user selects an item.

If you want to display different sets of a diagram item’s properties depending on certain condition, you can handle the CustomGetEditableItemPropertiesCacheKey event.

The following example demonstrates a custom shape that derives from the DiagramShape. When the ShowInfo property value is set to true , the property grid displays the Info property.

csharp
//DiagramShapeEx.cs
public class DiagramShapeEx : DiagramShape {
    //the NotifyParentProperty attribute is used to notify the DiagramControl
    //that the ShowInfo value has changed.
    [NotifyParentProperty(true)]
    public bool ShowInfo {
        get;
        set;
    }
    public string Info {
        get;
        set;
    }
}
csharp
void diagramControl1_CustomGetEditableItemProperties(object sender, DiagramCustomGetEditableItemPropertiesEventArgs e) {
    DiagramShapeEx shapeEx = e.Item as DiagramShapeEx;
    if (shapeEx != null) {
        e.Properties.Add(TypeDescriptor.GetProperties(typeof(DiagramShapeEx))["ShowInfo"]);
        if (shapeEx.ShowInfo)
            e.Properties.Add(TypeDescriptor.GetProperties(typeof(DiagramShapeEx))["Info"]);
    }
}

void diagramControl1_CustomGetEditableItemPropertiesCacheKey(object sender, DiagramCustomGetEditableItemPropertiesCacheKeyEventArgs e) {
    if (e.Item is DiagramShapeEx)
        e.CacheKey = Tuple.Create(typeof(DiagramShapeEx), ((DiagramShapeEx)e.Item).ShowInfo);
}

Tip

If you have a reasonable number of shapes on the canvas, you can set the e.CacheKey to null without affecting the performance.

See Also

CustomGetEditableItemProperties

DiagramControl Class

DiagramControl Members

DevExpress.XtraDiagram Namespace