开发者

how can i get value of the selected index on double click of the listview of winform?

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 an开发者_StackOverflow社区y Idea regarding the same ?

thanks in advance. Manish.


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");
}


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜