
How to count the checked ListView items
Yes, I could be better. But I wonder if Windows supports this, meaning: Is
there a API call for getting the number of checkmarked items. I know there
is a API call for getting the number of selected items in the listview
control.
The VB code which loops trough each item of the listview control will work,
but wil be noticeable slow, especially when there are a large number of
listitems in the listview control.
Thats my problem.
Quote:
> Why do you think it could be better?
> --
> Mikhail Berlyant
> Brainbench MVP for Visual Basic
> http://www.brainbench.com
> Distribution Systems Lead, Data Systems
> http://www.launch.com
> > Thanks Mikhail ,
> > the kind of code I was waiting for, would look like this:
> > Public Function CountSelected(ByRef lvwCurr As ListView) As Integer
> > ' DLV.
> > Dim lResult As Integer
> > ' API Call functie aanroepen.
> > lResult = SendMessage(lvwCurr.hwnd, LVM_GETSELECTEDCOUNT, 0, ByVal
0&)
> > ' Functieresultaat doorgeven aan functiewaarde.
> > CountSelected = CInt(lResult)
> > End Function
> > However, because I couldn't find a sort of "LVM_GETMARKEDCOUNT"
anywhere,
> I
> > going to use your code sample.
> > Thanks again.
> > > Dim i As Long
> > > Dim lngCheckedItems As Long
> > > With ListView1.ListItems
> > > For i = 1 To .Count
> > > lngCheckedItems = lngCheckedItems - .Item(i).Checked
> > > Next
> > > End With
> > > --
> > > Mikhail Berlyant
> > > Brainbench MVP for Visual Basic
> > > http://www.brainbench.com
> > > Distribution Systems Lead, Data Systems
> > > http://www.launch.com
> > > > Question about the ListView control:
> > > > If I want to know the number of checked (not selected!) items in a
> > > ListView
> > > > control, do I have to use a API Call, or can I use a VB Function?
> > > > Greetings,
> > > > Stefan