views:

16

answers:

1

I have a list of some custom classes and an UserControl to edit one instance of the class. I want to have a control on a form which allows to add a new instance, delete an instance and edit any instance. What can you suggest for that?

The control should take less space than all UserControls for existing object instance (i.e. have some folding). Estimate maximum number of objects in the collection is 5-7.

A: 

There is no built in control that will provide this functionality for you. I would recommend that you copy the same approach that is used at design time for editing collections. You have a ListBox on the left with a list of the collection entries. On the right you have a PropertyGrid that shows properties of the currently selected instance in the ListBox. This allows editing of an existing item. Alternatively you could use your own custom UserControl. Then add a Delete button for removing entries and Add button for adding new owns. Pressing the Add button would present a dialog allowing you to select which of the possible types you want to create.

Phil Wright