Skip to main content

QueryCheckStateByValueEventArgs.Value Property

Gets the current edit value.

Namespace: DevExpress.XtraEditors.Controls

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation


public object Value { get; }

Property Value

Type Description

A Object expression representing an editor’s edit value.


This example demonstrates how to handle RepositoryItemCheckEdit.QueryCheckStateByValue and RepositoryItemCheckEdit.QueryValueByCheckState events in order to use a check editor to display and modify data from the bound data field.

The example assumes that a check editor is bound to a specific dataset field whose type is not obviously known and should be determined programmatically. The available data types that the field can take on are boolean, string and integer. So the field can contain the following combinations representing an option value (these values will be used to set the editor’s CheckEdit.EditValue property):

  • True, False - for the boolean type;
  • Yes“, “No“, “?“ - for the string type;
  • 1, 0, -1 - for the integer type.

It is evident that making use of RepositoryItemCheckEdit.ValueChecked, RepositoryItemCheckEdit.ValueUnchecked and RepositoryItemCheckEdit.ValueGrayed properties is insufficient in this case. Thus, the example requires and implements a custom “edit value -> check state” and “check state -> edit value” conversion logic, which is illustrated by the sample code below.

using DevExpress.XtraEditors.Controls;

private void checkEdit1_QueryCheckStateByValue(object sender, QueryCheckStateByValueEventArgs e) {
    string val = e.Value.ToString();
    switch (val) {
        case "True":
        case "Yes":
        case "1":
            e.CheckState = CheckState.Checked;
        case "False":
        case "No":
        case "0":
            e.CheckState = CheckState.Unchecked;
            e.CheckState = CheckState.Indeterminate;
    e.Handled = true;

private void checkEdit1_QueryValueByCheckState(object sender, QueryValueByCheckStateEventArgs e) {
    CheckEdit edit = sender as CheckEdit;
    object val = edit.EditValue;
    switch (e.CheckState) {
        case CheckState.Checked:
            if (val is bool) e.Value = true;
            else if (val is string) e.Value = "Yes";
            else if (val is int) e.Value = 1;
            else e.Value = null;
        case CheckState.Unchecked:
            if (val is bool) e.Value = false;
            else if (val is string) e.Value = "No";
            else if (val is int) e.Value = 0;
            else e.Value = null;
            if (val is bool) e.Value = false;
            else if (val is string) e.Value = "?";
            else if (val is int) e.Value = -1;
            else e.Value = null;
    e.Handled = true;
See Also