本文介绍了可靠的方法来取消ItemCheck事件上的CheckedListBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道的一种可靠的方法来取消对的CheckedListBox的ItemCheck事件?我是在一个情况下的ItemCheck事件应该基本上放弃在窗体上的变化,但是,如果一个人决定取消丢弃我想ItemCheck事件不火,以免改变什么。
Does anyone know of a reliable way to cancel the ItemCheck event on a CheckedListBox? I am in a situation where the ItemCheck event should basically discard changes on a form, however, if the person decides to cancel the discard I would like the ItemCheck event not to fire so as not to change anything.
推荐答案
这是很容易做的ItemCheck事件。刚刚设置的值回。像这样的:
It is easy to do with the ItemCheck event. Just set the value back. Like this:
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) {
if (someCondition) e.NewValue = e.CurrentValue;
else {
// Regular stuff
//...
}
}
这篇关于可靠的方法来取消ItemCheck事件上的CheckedListBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!