public void SetItemCheckState (int index, CheckState value)
{
if (index < 0 || index >= Items.Count)
throw new ArgumentOutOfRangeException ("Index of out range");
if (!Enum.IsDefined (typeof (CheckState), value))
throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for CheckState", value));
CheckState old_value = GetItemCheckState (index);
if (old_value == value)
return;
ItemCheckEventArgs icea = new ItemCheckEventArgs (index, value, old_value);
OnItemCheck (icea);
switch (icea.NewValue) {
case CheckState.Checked:
case CheckState.Indeterminate:
check_states[Items[index]] = icea.NewValue;
break;
case CheckState.Unchecked:
check_states.Remove (Items[index]);
break;
default:
break;
}
UpdateCollections ();
InvalidateCheckbox (index);
}