views:

21

answers:

2

Hi all,

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.

+1  A: 

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");
}
Hemant
+1  A: 

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;
ho1
MouseDoubleClick event is not fire,don't now why...
Manish
@Manish: In those situations it can sometimes be helpful to create a new very basic project that mimics just the functionality you want to test (so a basic winforms project with a listview with some items and you try to handle the double click). If that works, you can try to copy more of the listview functionality from your real project to this test project to see if you can find which bit of your real project is making it not work.
ho1
Actually Problem was i am using the Dragging of the Item in listviewSo it's overrides the Doubleclick, but solved.i have used the e.clicks when mouseDown Events is fire.thanks.
Manish