如何prevent SelectedIndexChanged事件时,数据源绑定? [英] How to prevent selectedindexchanged event when DataSource is bound?
本文介绍了如何prevent SelectedIndexChanged事件时,数据源绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有ComboBox控件(WinForm的项目)。
I have ComboBox control(WinForm project).
当我绑定数据源的ComboBox控件combobox_selectedindexchanged事件。
When I bind DataSource to the ComboBox control combobox_selectedindexchanged event is fired.
不知道如何prevent SelectedIndexChanged事件时,数据源绑定?
Any idea how to prevent selectedindexchanged event when DataSource is bound?
推荐答案
删除处理程序SelectedIndex_Changed事件,绑定您的数据,然后再添加处理程序了。以下是如何可能的方法内完成一个简单的例子:
Remove the handler for the SelectedIndex_Changed event, bind your data, then add the handler back. Following is a simple example of how this might be done within a method:
private void LoadYourComboBox()
{
this.comboBox1.SelectedIndexChanged -= new EventHandler(comboBox1_SelectedIndexChanged);
// Set your bindings here . . .
this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
}
这篇关于如何prevent SelectedIndexChanged事件时,数据源绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文