【发布时间】:2021-12-17 20:44:52
【问题描述】:
我的列表框中有一些项目,当我双击其中一项时,我希望 MessageBox 显示我双击的项目的信息。例如,我单击一个项目“Item 1”,MessageBox 显示为“Item 1”文本。这是我现在的解决方案,但它返回项目的索引,而不是实际项目:
private void empLbx_MouseDoubleClick(object sender, MouseEventArgs e)
{
int index = this.empLbx.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)
{
MessageBox.Show(index.ToString());
}
}
【问题讨论】:
标签: c# .net winforms listbox double-click