如何知道触发了哪个组合框事件 [英] How to know on which combo box event fired
问题描述
我在12组框中有84个组合框,在12组中。组合框命名为cb1,cb2,cb3,cb4,cb5,cb6,......组框命名为gBox1,gBox2 ,gBox3,gBox4,gBox5,....现在我想在选择或更改任何组合框的项目时将项目名称保存在变量中。我知道如果我为每个组合框使用SelectedIndexChanged,那么我可以得到我想要的东西,我想知道这是唯一的方法....或者有任何简化的方法来实现上述目的。
我欢迎任何建议/建议/指导。
关心所有
I have 84 combo box inside 12 group box, in a group of 12. Combo Box are named as cb1,cb2,cb3,cb4,cb5,cb6,...... Group Box are named as gBox1,gBox2,gBox3,gBox4,gBox5,.... Now I want to save the item name in a variable when I select or change item of any combo box. I know that if I use SelectedIndexChanged for each combo box then I can get what I want, I am wondering that is the only way to do.... OR there is any simplified way to achieve the above mentioned purpose.
I welcome any suggestion/advice/guidance.
Regards to all
推荐答案
尝试:
Try:
private void myComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
if (cb != null)
{
...
}
}
这篇关于如何知道触发了哪个组合框事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!