Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

list view control

Posted on 2000-03-07
4
Medium Priority
?
181 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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

971 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