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 CheckImage property to change the check box appearance. Use the RadioImage property to change the radio button appearance. Use the PartialCheck property to allow partial check feature within the column. 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 ComboBox1.Items
    .CellHasCheckBox(.FocusItem, 0) = True
    .CellState(.FocusItem, 0) = 1
End With

The following VB sample displays a message the user clicks a check box:

Private Sub ComboBox1_InsertItem(ByVal Item As EXCOMBOBOXLibCtl.HITEM)
    With ComboBox1.Items
        .CellHasCheckBox(Item, 0) = True
    End With
End Sub

Private Sub ComboBox1_CellStateChanged(ByVal Cell As EXCOMBOBOXLibCtl.HCELL)
    With ComboBox1.Items
        Debug.Print "The cell """ & .CellCaption(, Cell) & """ has changed its state. The new state is " & IIf(.CellState(, Cell) = 0, "Unchecked", "Checked")
    End With
End Sub

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

#include "Items.h"
CItems items = m_combobox.GetItems();
COleVariant vtItem( items.GetFocusItem() ), vtColumn( long(0) );
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 AxComboBox1.Items
    .CellHasCheckBox(.FocusItem, 0) = True
    .CellState(.FocusItem, 0) = 1
End With

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

axComboBox1.Items.set_CellHasCheckBox(axComboBox1.Items.FocusItem, 0, true);
axComboBox1.Items.set_CellState(axComboBox1.Items.FocusItem, 0, 1);

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

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

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

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

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

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 ComboBox1
    .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), ComboBox1.Columns(0).Caption) = True
End With