ListView Item added Event?

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
 
L

Larry Lard

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.
 
L

Larry Lard

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.
 
A

Atul

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top