By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

What event am I supposed to use?

P: n/a
TJ
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
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

"TJ" <an*******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
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.

.................................................. ...................TJ

Nov 16 '05 #2

P: n/a
TJ
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
Nov 16 '05 #3

P: n/a
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]
- mv*@spam.guard.caspershouse.com

"TJ" <an*******@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
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

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.