Please read entire question first to understand where I would have the ability to reset the default value of a property.
When defining a custom class that can be visually designed, one can implement a collections editor to modify properties which are lists, arrays, collections, using the following pattern:
[Editor(typeof(CollectionEditor), typeof(UITypeEditor)),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ElementCollection Elements
{
get;
}
Editing the Elements
property of this class will now launch a CollectionEditor
dialog, with a list of members on the left and a PropertyGrid
on the right.
The problem is, it appears that context menus are disabled for this property grid. Therefore, I cannot right click on a property to 'reset' its value to default, despite having a [DefaultValue]
attribute defined.
Yet, the DefaultValue
attribute is recognized, because the property is not serialized (and correctly displayed in unbolded text within the grid).
I would like to know how to enable this context menu on the PropertyGrid
from the CollectionEditor
dialog:
or alternatively, any way (hot key, etc.) that can be implemented to be able to reset these collection item properties.
CollectionEditor
s: How do you create a custom collection editor form for use with the property grid? – Limulus