开发者

WinForms control for editing of a custom object collection

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 ca开发者_高级运维n 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜