Items in ListView changed [modified]
-
Is there an event that raise if the collection of ListViewItems in the ListView has been changed?
modified on Tuesday, February 19, 2008 11:22 AM
Looking at the documentation it appears that you do not have such an event. But since the ListView can take a list of objects, you can have your objects either expose an event or a IsDirty property to indicate if values have changed within them.
-
Is there an event that raise if the collection of ListViewItems in the ListView has been changed?
modified on Tuesday, February 19, 2008 11:22 AM
Do you mean the collection being changed (i.e. an item added) or an item in the collection? If the first then not specifically for an Item(s) being added. The Invalidated event is raised but it's raised for other things too so may not be useful. You could create your own class that inherits from ListView.ListViewItemCollection and override the Add method and raise your own event in there, or simply create your own event elsewhere and raise it every time you call the Add or AddRange methods. You may need to do the same for the remove methods and clear methods as well.
Dave
-
Do you mean the collection being changed (i.e. an item added) or an item in the collection? If the first then not specifically for an Item(s) being added. The Invalidated event is raised but it's raised for other things too so may not be useful. You could create your own class that inherits from ListView.ListViewItemCollection and override the Add method and raise your own event in there, or simply create your own event elsewhere and raise it every time you call the Add or AddRange methods. You may need to do the same for the remove methods and clear methods as well.
Dave
I also tried to inherit an own class from ListViewItemCollection and raise a Changed event if any item were added or removed, but i don't know how to set the inherited class to the ListView.Items collection. Therefore i inherit an own ListView2 from the ListView class and tried to set the Items:
base.Items = new ListViewItemCollection2();
But base.Items is readonly...