I have a custom control that has an Items
property. I Have applied an EditorAttribute
with a UITypeEditor
of type CollectionEditor
.
Collection Type:
[Serializable]
[Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
public class ListItemsCollection : CollectionBase
{
// methods
}
Property Declaration In The Control:
private new ListItemsCollection _Items;
[Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
public new ListItemsCollection Items
{
get
{
return _Items;
}
set
{
_Items = value;
// do other UI changes
}
}
Problem:
When I drop this control to the designer surface, I am able to add items to the Items property using the PropertyGrid
. But, the when I click the Ok
button of the CollectionEditor
the setter of the Items
property is not getting called.
AFAIK when a value is returned from the EditValue
method of a UITypeEditor
class the setter block of the property is supposed to be called.
This is driving me insane. I even tried adding Event
's to the ListItemsCollection
, so that when Items are added, I can whatever I want with the control's ui.
This is not supposed to be hard. What am I doing wrong?