有谁知道的一种可靠的方法来取消对的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
//...
}
}