WinForm CheckBox
control implements both CheckedChanged
and CheckStateChanged
events. As far as I can tell both fire when the checked status of the checkbox is changed.
CheckedChanged
precedes CheckStateChanged
, but other than that I see no difference. Am I missing something? Should one be preferred over another?
views:
492answers:
2
+2
A:
My guess would be that it has to do with tri-state checkboxes. This is the guts of the CheckState setter:
if (this.checkState != value)
{
bool flag = this.Checked;
this.checkState = value;
if (base.IsHandleCreated)
{
base.SendMessage(0xf1, (int) this.checkState, 0);
}
if (flag != this.Checked)
{
this.OnCheckedChanged(EventArgs.Empty);
}
this.OnCheckStateChanged(EventArgs.Empty);
}
Jacob G
2010-05-06 16:16:44
+1
A:
CheckState (and thus CheckStateChanged) allow for using a checkbox that can have three values: it can be checked, unchecked or 'indeterminate' - i.e. it has ThreeState set to true.
If you're not using ThreeState, then CheckedChanged is all you need.
Stuart Dunkeld
2010-05-06 16:16:50