tags:

views:

46

answers:

2

Pretty straight forward question, but I can't find a way to do it.

When a user double clicks an item in my ListView I want to save the index number of the clicked item.

A: 

Assuming that you have a reference to the ListViewItem:

listView.Items.IndexOf(listViewItem)

Or just access listView.SelectedIndices in the Activate event handler -- if your ListView is single-select then there'll be only one index in there.

itowlson
A: 

It depends on which ListView you're using. All three have a property to get the selected item's index:

For Windows Forms, use ListView.SelectedIndices

For WPF, use ListView.SelectedIndex

For Web, use ListView.SelectedIndex

Reed Copsey