Solved

list view control

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

746 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

10 Experts available now in Live!

Get 1:1 Help Now