property Items.CellState([Item as Variant], [ColIndex as Variant]) as Long

Retrieves or sets the cell's state. Affects only check and radio cells.

TypeDescription
Item as Variant A long expression that indicates the item's handle.
ColIndex as Variant A long expression that indicates the cell's handle or the column's index, a string expression that indicates the column's caption or the column's key.
Long A long value that indicates the cell's state.

Use the CellState property to change the cell's state. The CellState property has effect only for check and radio cells. Use the CellHasCheckBox property to assign a check box to a cell. Use the CellHasRadioButton property to add a radio button to a cell. The control fires the CellStateChanged event when user changes the cell's state. Use the PartialCheck property to allow partial check feature within the column. Use the CheckImage property to change the check box appearance. Use the RadioImage property to change the radio button appearance. Use the FilterType property on exCheck to filter for checked or unchecked items.

The following VB sample adds a check box that's checked to the focused cell:

With Grid1.Items
    .CellHasCheckBox(.FocusItem, Grid.FocusColumnIndex) = True
    .CellState(.FocusItem, Grid.FocusColumnIndex) = 1
End With

The following C++ sample adds a check box that's checked to the focused cell:

#include "Items.h"
CItems items = m_grid.GetItems();
COleVariant vtItem( items.GetFocusItem() ), vtColumn( long(m_grid.GetFocusColumnIndex()) );
items.SetCellHasCheckBox( vtItem, vtColumn, TRUE );
items.SetCellState( vtItem, vtColumn, 1 );

The following VB.NET sample adds a check box that's checked to the focused cell:

With AxGrid1.Items
    .CellHasCheckBox(.FocusItem, AxGrid1.FocusColumnIndex) = True
    .CellState(.FocusItem, AxGrid1.FocusColumnIndex) = 1
End With

The following C# sample adds a check box that's checked to the focused cell:

axGrid1.Items.set_CellHasCheckBox(axGrid1.Items.FocusItem, axGrid1.FocusColumnIndex, true);
axGrid1.Items.set_CellState(axGrid1.Items.FocusItem, axGrid1.FocusColumnIndex, 1);

The following VFP sample adds a check box that's checked to the focused cell:

with thisform.Grid1.Items
	.DefaultItem = .FocusItem
	.CellHasCheckBox( 0, thisform.Grid1.FocusColumnIndex ) = .t.
	.CellState( 0,thisform.Grid1.FocusColumnIndex ) = 1
endwith

The following sample shows how to change the state for a cell to checked state: Grid1.Items.CellState(Grid1.Items(0), 0) = 1, 

The following sample shows how to change the state for a cell to unchecked state: Grid1.Items.CellState(Grid1.Items(0), 0) = 0, 

The following sample shows how to change the state for a cell to partial checked state: Grid1.Items.CellState(Grid1.Items(0), 0) = 2

The following sample displays a message when a cell of radio or check type has changed its state:

Private Sub Grid1_AddItem(ByVal Item As EXGRIDLibCtl.HITEM)
    Grid1.Items.CellHasCheckBox(Item, 0) = True
End Sub

Private Sub Grid1_CellStateChanged(ByVal Item As EXGRIDLibCtl.HITEM, ByVal ColIndex As Long)
    Debug.Print "The cell """ & Grid1.Items.CellValue(Item, ColIndex) & """ has changed its state. The new state is " & IIf(Grid1.Items.CellState(Item, ColIndes) = 0, "Unchecked", "Checked")
End Sub

Note: The intersection of an item with a column defines a cell. Each cell is uniquely represented by its handle. The cell's handle is of HCELL type, that's equivalent with a long type. All properties of Items object that have two parameters Item and ColIndex, refer a cell.

The following lines are equivalents and each of them changes the bold font attribute of the first cell on the first item.

With Grid1
    .Items.CellBold(, .Items.ItemCell(.Items(0), 0)) = True
    .Items.CellBold(.Items(0), 0) = True
    .Items.CellBold(.Items(0)) = True
    .Items.CellBold(.Items.ItemByIndex(0)) = True
    .Items.CellBold(.Items.ItemByIndex(0), 0) = True
    .Items.CellBold(.Items(0), Grid1.Columns(0).Caption) = True
End With