Custom items in a ListView control

I need to add a custom element to a ListView control (like in the picture), is this possible? And if so, what is the best way to do this? enter image description here

+4
source share
3 answers

I do not know what is possible with Winforms. The list items in System.Windows.Forms.ListView are System.Windows.Forms.ListView objects contained in a strongly typed collection.

You can try to subclass ListViewItem , but since this class is inherited directly from System.Object and is not the actual window shape control, you can borrow the problem since you will need to replicate all the functions of the inheritance chain of the actual control.

Now, if you are not too involved in the project, you can consider switching to WPF. A ListView in WPF uses controls as elements, so you can easily create a custom control that will be used as list items.

You may be able to find a control library with a control that will give you the necessary functionality, but for the most part, good libraries are commercial and can be prohibitively expensive for small stores and individuals.

I quickly looked through Google for any library that offers this feature, but I could not find the one that displayed user controls.

+2
source

Not sure if this is what you need, but ListViewItems has a Tag property that can store user data for each item.

http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.tag.aspx

0
source

How to create a custom control. In this case, you can install user controls at the top and list below. Or are you trying to add these controls as elements in the list itself?

0
source

Source: https://habr.com/ru/post/1341431/


All Articles