Click here to Skip to main content
15,918,404 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I currently have a list containing Call's, which is the base class. If I want to add derived classes of Call to the list, I know to do the following.
C#
public class CustomCollectionEditor : System.ComponentModel.Design.CollectionEditor
{
  private Type[] types;
  public CustomCollectionEditor(Type type)
    : base(type)
  {
    types = new Type[] { typeof(Call), typeof(BlueCall), typeof(CappedCall) };
  }

  protected override Type[] CreateNewItemTypes()
  {
    return types;
  }
}


MIDL
public class DisplayList
{
  public DisplayList() { }
  [Editor(typeof(CustomCollectionEditor), typeof(UITypeEditor))]
  [DataMember] public List<Call> ListCalls { get; set; }
}


My questions is there anyway of moving where you mark up the Type[] containing all possible types the list can contain? I thought of adding the following to my CustomCollectionEditor class, but this doesn't work.
public CustomCollectionEditor(Type type, List<Type> types_)
  : base(type)
{
  types = types_.ToArray();
}

It would be ideal if I could mark up which classes the CustomCollectionEditor needed to be aware of in the DisplayList class somehow.
Posted
Updated 5-Mar-10 8:18am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900