You need to create a class that defines the type of object that the collection identifiers consist of. ListView has ListViewItem objects. TabControl has TabPage objects. Your control has objects that you define. Let me call it MyItemType.
You also need a wraper class for the collection. The following is a simple implementation.
public class MyItemTypeCollection : CollectionBase { public MyItemType this[int Index] { get { return (MyItemType)List[Index]; } } public bool Contains(MyItemType itemType) { return List.Contains(itemType); } public int Add(MyItemType itemType) { return List.Add(itemType); } public void Remove(MyItemType itemType) { List.Remove(itemType); } public void Insert(int index, MyItemType itemType) { List.Insert(index, itemType); } public int IndexOf(MyItemType itemType) { return List.IndexOf(itemType); } }
Finally, you need to add the member variable for the collection to your user control and decorate it correctly:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public MyItemTypeCollection MyItemTypes { get { return _myItemTypeCollection; } }
and now you have a simple interface that allows you to view and edit the collection. There is still much to be desired, but in order to do more, you will need to learn about custom designers that are difficult to understand and implement.
source share