Link to home
Start Free TrialLog in
Avatar of smcintire001
smcintire001Flag for United States of America

asked on

Loop through selecteditem in listview with multiselect set to true

Visual Basic 6
Listview w/ mutliselect

How can I loop through all selected items in a listview without looping through all items and checking to see if the item is checked?
Avatar of andrewbleakley
andrewbleakley
Flag of Australia image

http://www.developerfusion.co.uk/show/148/

Using this method will return only the selected items. It uses the Windows API to Send the Get Selected Items Message to the List.

Let me know if you need help implementing it
Avatar of smcintire001

ASKER

That solution says its for a listbox.
Will it work for a listview as well?
ASKER CERTIFIED SOLUTION
Avatar of andrewbleakley
andrewbleakley
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm not sure that you can get through a list view and find only the select items... but this should work for you.


For x= 1 to ListView1.ListItems.Count
    If ListView1.ListItems(x).Selected Then
        'the rest of your code goes here
    End If
Next

NG,
Andrew:
Yes, I will need help implementing this.
Some of the constants aren't listed in the sample code (LV_ITEM, LVIF_TEXT, etc.).