amirl
asked on
list view control
I want to know how can i know the number of items
that were selected in the list view control.
thank you in advance.
that were selected in the list view control.
thank you in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you tried this: ListView1.SelectedItem.Lis tSubItems. Count
The other way can be SendMessage with parameter:
LVM_GETSELECTEDCOUNT (LVM_FIRST + 50)
LVM_GETSELECTEDCOUNT (LVM_FIRST + 50)
I prefer the For Each technique.. no indexes / collection holes to worry about.. and it is just as fast.. <smile>.
<----- Code Begin ----->
Public Function xSelectedCount _
(byval ilvwListView as Listview) _
as Long
Dim itmWork as ListItem
Dim lngSelected As Long
For Each itmWork in ilvwListView
If itmWork.Selected _
Then
lngSelected = lngSelected + 1
End If
Next itmWork
xSelectedCount = lngSelected
End Function
<----- Code End ----->
To use this function..
Dim lngCount as Long
lngCount = xSelectedCount(Me.Listview 1)
<smile>
<----- Code Begin ----->
Public Function xSelectedCount _
(byval ilvwListView as Listview) _
as Long
Dim itmWork as ListItem
Dim lngSelected As Long
For Each itmWork in ilvwListView
If itmWork.Selected _
Then
lngSelected = lngSelected + 1
End If
Next itmWork
xSelectedCount = lngSelected
End Function
<----- Code End ----->
To use this function..
Dim lngCount as Long
lngCount = xSelectedCount(Me.Listview
<smile>