A newer version of this page is available. Switch to the current version.

CheckEdit.CheckState Property

Gets or sets the editor's check state.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v19.2.dll

Declaration

[DXCategory("Appearance")]
[DefaultValue(CheckState.Unchecked)]
public virtual CheckState CheckState { get; set; }

Property Value

Type Default Description
CheckState

Unchecked

The check editor's state.

Remarks

CheckEdit_AllowGrayed_ThreeStates.gif

A check editor can have two states (checked or unchecked), or three states (checked, unchecked, or indeterminate - also called the grayed state). The RepositoryItemCheckEdit.AllowGrayed property specifies if users may set a Check Editor to the indeterminate state. If you disable the RepositoryItemCheckEdit.AllowGrayed property for an editor in the indeterminate state, it continues to show as indeterminate (although the CheckState property will return the Unchecked value).

The following three properties allow you to set or determine the editor’s state:

CheckState

Checked

EditValue

Checked

true

true (or ValueChecked)

Unchecked

false

false (or ValueUnhecked)

Indeterminate

Returns true

null, Nothing (or ValueGrayed)

The code sample below changes the state order to indeterminate, checked, unchecked when users click on a three-state check edit.

ChangedCheckStates

checkEdit1.Properties.AllowGrayed = true;
checkEdit1.ReadOnly = true;
checkEdit1.MouseDown += CheckEdit1_MouseDown;

private void CheckEdit1_MouseDown(object sender, MouseEventArgs e)
{
    CheckEdit edit = sender as CheckEdit;
    switch (edit.CheckState)
    {
        case CheckState.Checked:
            edit.CheckState = CheckState.Unchecked;
            break;
        case CheckState.Indeterminate:
            edit.CheckState = CheckState.Checked;
            break;
        case CheckState.Unchecked:
            edit.CheckState = CheckState.Indeterminate;
            break;
    }
}
See Also