Reputation: 346
I need to add a custom item to ListView control (like on the picture), is it possible ? And if it is, what's the best way to do it ?
Upvotes: 5
Views: 7992
Reputation: 2442
I don't know that this is possible with Winforms. The list items in a System.Windows.Forms.ListView
are System.Windows.Forms.ListViewItem
objects contained in a strongly typed collection.
You could try to create a subclass of ListViewItem
, but since that class inherits directly from System.Object
and is not an actual windows form control, you might be borrowing trouble, as you would need to replicate all the functionality of the inheritance chain of an actual control.
Now, if you are not too far in to the project, you might consider looking at switching to WPF. The ListView in WPF uses controls as items, so you could easily create a usercontrol that you would use as your list items.
You might be able to find a control library with a control that gives you the functionality you want, but for the most part, the good libraries are commercial and can be prohibitively expensive for small shops and individual .
I did a quick google search for any library that offers this capability, but I could not find one that displayed custom controls.
Upvotes: 2
Reputation: 2666
How about creating a user control. In that case you can set your user controls at the top and listview below. Or are you trying to add these controls as items in the listview itself?
Upvotes: 0
Reputation: 17957
Not sure if this is what you're after, but ListViewItems have a Tag property that can store custom data about each item.
http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.tag.aspx
Upvotes: 0