Override Items property in a list view
-
Does anyone know how to override the Listview items property so that it will populate the listview with my custom ListViewItemCollection? I was able to use: ListViewItemsExtra m_ItemsExtra = new ListViewItemsExtra(); new public ListViewItemsExtra Items { get{ return m_ItemsExtra; } } this did override the property and adds my custom listview items to the collection, but they do not show up in the listview. I was hoping to overide the ListViewItemCollection and have it use my custom Item without redrawing the objects in the listview. Lamont Bullock
-
Does anyone know how to override the Listview items property so that it will populate the listview with my custom ListViewItemCollection? I was able to use: ListViewItemsExtra m_ItemsExtra = new ListViewItemsExtra(); new public ListViewItemsExtra Items { get{ return m_ItemsExtra; } } this did override the property and adds my custom listview items to the collection, but they do not show up in the listview. I was hoping to overide the ListViewItemCollection and have it use my custom Item without redrawing the objects in the listview. Lamont Bullock
I don't know if you can make the ListView using m_ItemsExtra instead of the, probably, private class member it uses to list its items. Why not trying a different thing? I mean.. if I want more/own functionality in "my" ListViewItem, I'd inherit ListViewItem. public class MyListViewItem : ListViewItem I can still use it with the ListView because it is implicitly casted to ListViewItem (I guess on the implicit cast).
-
I don't know if you can make the ListView using m_ItemsExtra instead of the, probably, private class member it uses to list its items. Why not trying a different thing? I mean.. if I want more/own functionality in "my" ListViewItem, I'd inherit ListViewItem. public class MyListViewItem : ListViewItem I can still use it with the ListView because it is implicitly casted to ListViewItem (I guess on the implicit cast).
Zarrab, Sorry for not being more clear on how I went about the Listview control. I did create a new Listview class and it does inherit the properties of the .net listview class. This is why I want to override the listview's items collection with my own. I tried creating a new property called ItemsExtra and a custom ListViewItemExtraCollection to store the ListViewItemsExtra class objects. using the get{} accessor I am able to add ListViewItemsExtra to the collection fine, but the IDE doesnt automatically create the code below that it does for a normal listview item. listViewExtra.addrange( new ListViewItemsExtra.ListViewItemsExtraCollection{ this.listViewItemExtra1, this.listViewItemExtra2, this.listViewItemExtra3, etc } ) If I could override the Items property and have it add my custom ItemsExtra object or override the Add() method on the ListViewItemCollection class I may be able to successfully get the ItemExtras in the listview without haveing to redraw them with code. It also works to change the code for a normal listview item to my ItemsExtra object, but that isn't clean like I would like. I want to be able to re-use the control whenever I need it, with the ease of other controls and not have to jerry rig code. Do you have any suggestions? Lamont Bullock