C#将点击事件添加到列表框 [英] C# adding click events to a list box
本文介绍了C#将点击事件添加到列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将单击事件添加到列表框中,但是由于某些原因,当我单击列表框中的项目时没有任何反应.
I'm trying to add a click event to a list box but for some reason nothing happens when I click an item in my list box.
我的猜测以及从我读过的内容来看,代码应该看起来像这样
My guess and from what I've read, the code should look something like this
private void listBox1_Click(object sender, EventArgs e)
{
//Code Ex. TextBox1.Text = "Success";
}
那是行不通的.有人知道如何实现这一目标吗?也不介意知道双击和其他点击的变化....
That's not working though. Anyone know how to get this to happen? Wouldn't mind knowing the double click and other click variations too....
推荐答案
如果您希望在单击框中的项目"时触发它,为什么不试试SelectedIndexChanged?
If you want it to trigger when you 'click an item' in the box, why don't you try SelectedIndexChanged instead?
这篇关于C#将点击事件添加到列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文