I have a Property Grid which I am trying to use to display a complex object.

The object in question contains a collection of objects that all derive from the same abstract class. I want to be able to use the property grid to add new items to that collection.

I have used a type converter to allow that object to appear as expandable so that I can access it's properties (including the collection). When I attempt to add new items to the collection I receive errors because the class it is trying to create is the abstract base class rather than the child classes.

How can I make it so that when you attempt to add a new item to that collection, it will ask you what type of object to create (instead of defaulting to the abstract base class).

To give you a better understanding, my structure is something like this:

public class class1
{
private class2[] collection;

public class2[] Collection
{
get{ return collection; }
set{ collection = value; }
}
}

// When adding to the collection, it attempts to create an instance of this
// class which fails. It needs to have a way to determine whether to create
// an instance of class3 or class4 instead.
[TypeConverter(typeof(Class2TypeConverter))]
public abstract class2
{

}

public class3 : class2
{
}

public class4 : class2
{
}