I have derived a collection editor for my collection class. but the add and delete button in the collection editor is not enabled so that i could not add or delete a instance in collection through designer.
Here is the code i have used,
[EditorAttribute(typeof(MyCollectionEditor), typeof(UITypeEditor))]
public MyCollection : IDisposable, ICollection
{
List<MyClass> list= new List<MyClass>();
public Add(MyClass myclass)
{
}
......
}
public class MyCollectionEditor : CollectionEditor
{
public MyCollectionEditor ()
: base(typeof(MyCollection))
{
}
protected override Type CreateCollectionItemType()
{
return typeof(MyCollection);
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
return base.EditValue(context, provider, value);
}
}
Could anyone please let me know, how to enable add, delete buttons in collection editor and make it work for my collection?
Regards,
Try this:
This should enable "Add" and "Remove" buttons.