我正在尝试加载具有不同信息的表单,具体取决于我双击列表框的哪个组件。如果我知道点击了哪个框(框 1、框 2 等),那就足够了。
我试过使用 Doubleclick 事件,但它返回一个对象,我不太确定如何处理这个对象来获得我需要的东西。
这是我现在的代码:
for (int i = 0; i <= (Program.Customers.Count) - 1; i++)
{
if (Program.Customers[i].Name == searchTerm)
{
SearchIndex.Add(i);
listBox1.Items.Add(((Program.Customers[i].ID + " - " + Program.Customers[i].Name)));
}
}
listBox1.Show();
获取单击哪个框的最佳方法是什么?我需要 ID,但我可以通过单击框来获取它。
谢谢!