我有一个包含一些项目的列表框.无论如何我可以为每个项目附加一个双击事件吗?
I have a list box with some items. Is there anyway I can attach a double click event to each item?
Item 1
Item 2
Item 3
如果我要双击第 2 项,会弹出一个显示第 2 项"的消息框
If i was to double click Item 2, a Messagebox saying "Item 2" would pop up
我该怎么做?
void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
int index = this.listBox1.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)
{
MessageBox.Show(index.ToString());
}
}
这应该可以工作...检查
This should work...check
这篇关于C# 列表框项双击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!