Solved

list view control

Posted on 2000-03-07
4
162 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 70

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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