ListView Item added Event?

  • Thread starter Thread starter Matt Gabbard
  • Start date Start date
M

Matt Gabbard

Can someone think of a way or an event that is fired when an item is added
to a listview? I have a running total box which needs to stay updated every
time a listviewitem is added or removed, but can not find an event fired on
these occasions...


Thanks,

Matt
 
Matt said:
Can someone think of a way or an event that is fired when an item is added
to a listview? I have a running total box which needs to stay updated every
time a listviewitem is added or removed, but can not find an event fired on
these occasions...

One way that should work is to subclass ListView and
ListViewItemCollection to create derived classes that raise the events
you are after, then to use instances of those derived classes on your
form. There may be easier ways. If no one comes up with anything
easier, and you need help with this method, just ask.
 
Larry said:
One way that should work is to subclass ListView and
ListViewItemCollection to create derived classes that raise the events
you are after, then to use instances of those derived classes on your
form. There may be easier ways. If no one comes up with anything
easier, and you need help with this method, just ask.

Following up myself, it seems someone has done this already: take a
look at

<http://www.codeproject.com/dotnet/observerlistview.asp>

Does some things differently from how I would, but it's all there.
 
There is no direct event for this, but you can catch the LVN_INSERTITEM and
LVN_DELETEITEM messages to keep track of items

----------------
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For .Net & ActiveX
Windows Explorer GUI Controls
&
Quick-Launch Like Appbars, MSN/Office2003 Style Popups,
System Tray Icons and Shortcuts/Internet Shortcuts
 
Back
Top