Count of Items selected in ListView

murthyspd

Registered User.
Local time
Today, 22:56
Joined
Aug 3, 2006
Messages
31
Hi
I have a ListView control on a MS Access form. I allow users to select multiple rows. Can i get a count of rows selected without having to scan through the list view. Similar to list box ItemsSelected property ?
 
Hi,

Yes, use the ListCount property.

Hi
I have a ListView control on a MS Access form. I allow users to select multiple rows. Can i get a count of rows selected without having to scan through the list view. Similar to list box ItemsSelected property ?
 
Hi
Listcount will give me the number of items in the list. I wanted count of items selected. So if I select 2 items out of 5, i should get 2 as the result.
 
Sorry, for not getting back to you soon.

You use the ListCount property in a For Next loop and use the Selected property to determine the boolean condition. Like….

Dim i As Long
Dim icount as Long

For i = 0 To ListView.ListCount - 1
If ListView.Selected(i) Then
icount = icount + 1
End If
Next i
MsgBox “Total Selected “ & icount

Hi
Listcount will give me the number of items in the list. I wanted count of items selected. So if I select 2 items out of 5, i should get 2 as the result.
 
Or, if you are using the ActiveX ListView in MSComCtlLib, it's not hard to "scan thru the list view"...
Code:
Public Property Get SelectedCount as Integer
  Dim item As MSComCtlLib.ListItem
  Dim i As Integer
  For Each item In YourList.ListItems
    If item.Selected Then i = i + 1
  Next item
  SelectedCount = i
End Property
 

Users who are viewing this thread

Back
Top Bottom