I have a listview which contains about 500 items. I was pretty confused when
I realized that it takes over 50 milliseconds to get
Listview.CheckedItems.Count value. How it can be so slow?
In ItemChecked event I have code which sets text "3 items selected" to a
label. When I turn CheckBoxes to True you can imagine how long it takes.
I'm using Visual Basic 2005.
Any good ideas?
Thanks,
Teemu
Cerebrus - 19 Mar 2006 07:21 GMT
Hi,
Virtual ListView seems the way to go.
There are many samples available. Don't know if they're available for
VS 2005.
Here's one that you can try :
http://www.windowsforms.com/ControlGallery/ControlDetail.aspx?Control=214&tabindex=9
Also, an MSDN article on how to create a Virtual Listview:
http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/downloads/
samples/internet/commctrl/vlistvw/default.asp
Hope this helps,
Regards,
Cerebrus.
Jason Newell - 20 Mar 2006 19:36 GMT
Teemu,
I would give LVM_GETITEMCOUNT a try to see if it's any faster.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platfor
m/commctls/listview/messages/lvm_getitemcount.asp
Declare Function SendMessage Lib "User32.dll" (ByVal hWnd As IntPtr,
ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer)
As IntPtr
LVM_FIRST = 0x1000
LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Jason Newell
> I have a listview which contains about 500 items. I was pretty confused
> when I realized that it takes over 50 milliseconds to get
[quoted text clipped - 9 lines]
> Thanks,
> Teemu
Jason Newell - 20 Mar 2006 21:27 GMT
Totally sorry, I missed the "Checked" statement. I'll repost if I can
think something else up.
Jason Newell
> Teemu,
>
[quoted text clipped - 25 lines]
>> Thanks,
>> Teemu
Claes Bergefall - 20 Mar 2006 21:21 GMT
Not surprising actually. CheckedItems.Count actually loops over all items in
your list box and counts the ones that are checked.
How about keeping a counter yourself? Then you only need to add or subtract
1 in the ItemChecked event
/claes
>I have a listview which contains about 500 items. I was pretty confused
>when I realized that it takes over 50 milliseconds to get
[quoted text clipped - 9 lines]
> Thanks,
> Teemu