What event am I supposed to use?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I placed one ListView control on a form
I would like to check how many items in the ListView control as real-time
In other words, whenever total item count of ListView control is chagend, I would like to get some notify so that I can do something...

For example, whenever add or remove operation is performed, event would be fired....
What event am I supposed to use for this one

Thanks

......................................................................T
 
TJ,

I would recommend limiting access to the list, and providing your own
methods for adding the items that are being shown by the ListView. This
way, you can know when items are being added or removed.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

TJ said:
Hi,

I placed one ListView control on a form.
I would like to check how many items in the ListView control as real-time.
In other words, whenever total item count of ListView control is chagend,
I would like to get some notify so that I can do something....
 
Thanks, Nicholas

I am just curious that..
Is there any supported event that I can use for checking of item number in ListView control
Something like this..

ListView.ItemCountChanged += new ItemCountChangedEventHandler(OnItemCountChanged)

private void OnItemCountChanged(......Event e)
MessageBox.Show(e.TotalCount); // TotalCount would be number of items in ListView in real-time so that I do not need to keep track variable for checking number of items in ListView control..


Thanks

.........................................................TJ
 
TJ,

No, there is not. You could override the WndProc method and check for
the LVM_DELETEITEM and LVM_INSERTITEM windows messages.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

TJ said:
Thanks, Nicholas.

I am just curious that...
Is there any supported event that I can use for checking of item number in ListView control?
Something like this...

ListView.ItemCountChanged += new ItemCountChangedEventHandler(OnItemCountChanged);

private void OnItemCountChanged(......Event e) {
MessageBox.Show(e.TotalCount); // TotalCount would be number of
items in ListView in real-time so that I do not need to keep track variable
for checking number of items in ListView control...
 
Back
Top