J
Joel G.
Hiya folks,
Does anybody know how to contain a list of abstract objects that is editable
by the designer? For example, say I have the following:
public abstract class Shapes: CollectionBase
{
public Shapes()
{
}
public Shape this[ int index ]
{
get { return (Shape)base.List[ index ]; }
}
public void Add( Shape item )
{
base.List.Add( item );
}
...
...
public class Shape
{
private int area;
public Shape()
{
area=0;
}
public int Area
{
get
{
return area;
}
set
{
area=value;
}
}
}
public class Square : Shape
{
private int size=0;
public Square()
{
}
public int Size
{
get
{
return size;
}
set
{
size=value;
}
}
}
And in my control I have:
[Category("Appearance"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
EditorAttribute(typeof(ListItemsCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public Shapes Shapes
{
get
{
return shapes;
}
set
{
shapes=value;
}
}
How do I let the user add circles or squares and yet still store all objects
in the same collection?
Joel
Does anybody know how to contain a list of abstract objects that is editable
by the designer? For example, say I have the following:
public abstract class Shapes: CollectionBase
{
public Shapes()
{
}
public Shape this[ int index ]
{
get { return (Shape)base.List[ index ]; }
}
public void Add( Shape item )
{
base.List.Add( item );
}
...
...
public class Shape
{
private int area;
public Shape()
{
area=0;
}
public int Area
{
get
{
return area;
}
set
{
area=value;
}
}
}
public class Square : Shape
{
private int size=0;
public Square()
{
}
public int Size
{
get
{
return size;
}
set
{
size=value;
}
}
}
And in my control I have:
[Category("Appearance"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
EditorAttribute(typeof(ListItemsCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public Shapes Shapes
{
get
{
return shapes;
}
set
{
shapes=value;
}
}
How do I let the user add circles or squares and yet still store all objects
in the same collection?
Joel