I have a CheckBox in my application that is using the TriState mode. The normal behavior for this mode seems to be cycling between null, false, true.
I\'d like to c
Only for completeness here additionally the solution for Windows-Forms. We have to override the OnClick method, overriding OnStateChanged results in display bug (and stackoverflow if done incorrectly).
///
/// A with the ability to reverse the checkstate order.
///
///
public class CheckBoxReversible : CheckBox
{
private bool FInvertCheckStateOrder;
///
/// Gets or sets a value indicating whether to invert the check state order from [Indeterminate->Unchecked->Checked] to [Indeterminate->Checked->Unchecked].
///
///
/// true to invert the check state order; otherwise, false .
///
public bool InvertCheckStateOrder
{
get { return FInvertCheckStateOrder; }
set { FInvertCheckStateOrder = value; }
}
///
/// Löst das -Ereignis aus.
///
/// Eine Instanz der -Klasse, die die Ereignisdaten enthält.
protected override void OnClick(EventArgs e)
{
if (this.InvertCheckStateOrder)
{
if (this.CheckState == CheckState.Indeterminate)
this.CheckState = CheckState.Checked;
else
if (this.CheckState == CheckState.Checked)
this.CheckState = CheckState.Unchecked;
else
if (this.CheckState == CheckState.Unchecked)
this.CheckState = this.ThreeState ? CheckState.Indeterminate : CheckState.Checked;
}
else
base.OnClick(e);
}
}