Solved

list view control

Posted on 2000-03-07
4
158 Views
Last Modified: 2012-06-27
I want to know how can i know the number of items
that were selected in the list view control.

thank you in advance.
0
Comment
Question by:amirl
4 Comments
 

Accepted Solution

by:
hSunderlin earned 50 total points
ID: 2592463
Dim x As Integer
Dim numSelected As Integer
For x = 1 To ListView1.ListItems.Count
  If istView1.ListItems.Itemx).Selected Then numSelected = numSelected + 1
Next x
MsgBox numSelected
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2592473
Have you tried this:     ListView1.SelectedItem.ListSubItems.Count
0
 
LVL 15

Expert Comment

by:ameba
ID: 2593121
The other way can be SendMessage with parameter:
LVM_GETSELECTEDCOUNT    (LVM_FIRST + 50)
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2594758
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.Listview1)

<smile>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LINQ return type for nested group query 6 74
JSON Response and request in VB6 application 11 252
Adding to a VBA? 6 63
VBA filters 2 51
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now