我需要使用combobox SelectedIndexChanged事件,但在某些情况下我想要点击按钮取消SelectedIndexChanged事件或与此事件相关的代码停止工作?
答案 0 :(得分:4)
ComboBox comboBox = new ComboBox();
订阅 SelectedIndexChanged 活动
comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged;
使用以下代码取消订阅 SelectedIndexChanged 事件
comboBox.SelectedIndexChanged -= comboBox_SelectedIndexChanged;
答案 1 :(得分:1)
有多种选择
答案 2 :(得分:1)
SelectedIndexChanged
答案 3 :(得分:0)
点击按钮后,您可以取消订阅如下所示的事件:
combo1.SelectedIndexChanged -= combo1_SelectedIndexChanged;