停止comboBox的selectedIndexChanged事件触发时,窗体加载 [英] Stop comboBox's selectedIndexChanged event from firing when the form loads

查看:253
本文介绍了停止comboBox的selectedIndexChanged事件触发时,窗体加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 ComboBox 的表单,提供了一个下拉列表。在comboBox的 SelectedIndexChanged事件,我运行一些代码,但我不希望该代码在表单加载时运行。不幸的是,当我加载表单(在我在组合框中选择之前),组合框的 SelectedIndexChanged fires(我认为当组合框 databinding )。是否有避免此类行为的方法?

I have a form with a ComboBox that provides a dropdownlist. On the comboBox's SelectedIndexChanged event, am running some code, but I don't want that code to run when the form loads. Unfortunately, when I load the form (before I make a selection in the combobox), SelectedIndexChanged of the combobox fires (I think when the combobox is databinding). Is there a way of avoiding such behaviour?

推荐答案

如果您只想在用户更改组合中的选定项目框,那么最好订阅 SelectionChangeCommitted

If you want to react only when the user change the selected item in the combo box, then it is better to subscribe to SelectionChangeCommitted.

这篇关于停止comboBox的selectedIndexChanged事件触发时,窗体加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆