PropertyGrid Editor for a property list with inherited classes
See the question and my original answer on StackOverflowYou can do it with a custom UITypeEditor attribute:
public class ContainerClass
{
...
[Editor(typeof(MyCollectionEditor), typeof(UITypeEditor))]
public List<ContainerBase> Containers { get; set; }
...
}
With this UITypeEditor:
public sealed class MyCollectionEditor : CollectionEditor // need a reference to System.Design.dll
{
public MyCollectionEditor(Type type)
: base(type)
{
}
protected override Type[] CreateNewItemTypes()
{
return new[] { typeof(ContainerBase), typeof(Bookbag), typeof(Bookcase) };
}
}
And this is how it will look: