简体   繁体   中英

C# ListView items with custom controls

I'm maintaining a C# application written with windows forms. I now need to have a list view where every item has a few custom controls.

Every item need to have title and a combobox. The problem is that the data for the custom boxes will be different. So for example Item 1 could have a ComboBox where you can pick 1-3. Item 2 would have a combo box where you can pick 1-2.

So in the property column I need a string, and in the value column a combobox, with different data sets for different items (or at least for different kinds of items)

在此处输入图片说明

I've been on this problem for a while, and I don't really know where to go from here.

Why don't you use a Property Grid control? It is composed by two columns, the left one being a fixed text for the key/title and the right one is dynamic, in the sense you can have comboboxes, textboxes, color selection controls, etc. for the value the user can input/select.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM