Reputation: 859
How can i can the Selected index of the listview when i double click on selected item ?
Also i have created a event DragEnter for the listview but due to this the double click event
is not firing.
So is there any Idea regarding the same ?
thanks in advance. Manish.
Upvotes: 1
Views: 5310
Reputation: 54999
If I understand correctly you want to know the Index of the item that was double clicked, you can do this by handling the MouseDoubleClick
event and adding this code in the handler:
int index = listView1.HitTest(e.Location).Item.Index;
Upvotes: 2
Reputation: 19826
Below works fine for me (even with DragEnter event handler):
private void listView1_DoubleClick (object sender, EventArgs e) {
if (listView1.SelectedIndices.Count > 0)
MessageBox.Show ("Selected Index is " + listView1.SelectedIndices[0]);
else
MessageBox.Show ("No item selected");
}
Upvotes: 2