Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListView

Status
Not open for further replies.

MaxZak

Programmer
Joined
Oct 5, 2001
Messages
116
Location
IT
I have a ListView with MultiSelect=True, how can I know witch Item has been clicked, without looping on each Item?

I need to process only the last clicked Item, but the "Click" event doesn't tell me anithing about the clicked Item.
I don't want to use the checks (in this case I would trap the ItemChecked event)

Thanks
 
The listbox has a selectedItems Collection.

You could use this
' Print the indices of all selected items
For i = 0 To listbox.selectedItems.count- 1 Step i + 1
'Do whatever you want to do here
messagebox.show(listbox.selectedItems(i))
Next

I am not sure if the last one selected will be at the top or the bottom of the collection but you can test it and then either use :

For i = 0 To listbox.selectedItems.count- 1 Step 1

or

For i = listbox.selectedItems.count- 1 to 0 Step -1



DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top