ListView getting the Selected Item
-
For a ListView with MultiSelect = false how do I find the label of the selected Icon? I’m hooking the SelectedIndexChanged event. And then it looks like I’m forced to iterate the SelectedItems collection with a foreach loop. This seems stupid since only one item can be selected when MultiSelect = false. I would like to do something like:
MyListView.Items(MyListView.SelectedIndex).Name
But there is no SelectedIndex property and does not look like I can use MyListView.Items in that way. Do I have to iterate the SelectedItems collection for the single selected Item? How do you guys do this?
-
For a ListView with MultiSelect = false how do I find the label of the selected Icon? I’m hooking the SelectedIndexChanged event. And then it looks like I’m forced to iterate the SelectedItems collection with a foreach loop. This seems stupid since only one item can be selected when MultiSelect = false. I would like to do something like:
MyListView.Items(MyListView.SelectedIndex).Name
But there is no SelectedIndex property and does not look like I can use MyListView.Items in that way. Do I have to iterate the SelectedItems collection for the single selected Item? How do you guys do this?
-
Thanks Draco, Not sure how I missed that one. I added this to the click event:
listView1.FocusedItem.Text
albean wrote: Not sure how I missed that one. Because it's not really a standard thing in the framework. Usually it's SelectedIndex or SelectedItem. You could also use the SelectedIndices property...and then the first selected index would be listView1.SelectedIndices[0].
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing