![](/img/trans.png)
[英]Unable to fire SelectedIndexChanged Event for a single item in a combobox
[英]How can combobox event handler fire after the item drops down?
我正在触发function MY_FUNCTIOND时,选择了combobox索引并根据选定的combobox选定的索引运行。
在这里我如何声明事件处理程序:
ComboBox1.SelectionChanged += new SelectionChangedEventHandler(ComboBox1_SelectionChanged);
combobox的事件处理程序:
private void ComboBox1_SelectionChanged(object sender, EventArgs e)
{
my_function();
}
还有我的函数:
private void my_function(){
if(ComboBox1.SelectedIndex == 0)
//do something
else{
//do something else
}
}
现在我的问题是,当我点击 combobox 时,程序在 combobox 项目下降之前开始执行代码。 所以它看起来像 combobox 在几秒钟后实际下降之前卡住了。 有没有可能先 combobox item 下降然后 my_function 执行?
使用SelectionChanged
的事件SelectionChangeCommitted
实例将在提交您的 select 时触发您的 function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.