Retrieves or sets the cell's state. Has effect only for check and radio cells.

| Type | Description | |||
| Item as Variant | A long expression that indicates the item's handle that indicates the owner of the cell. | |||
| ColIndex as Variant | A long expression that identifies the column's index, or a string expression that specifies 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 Tree1.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:
#include "Items.h" CItems items = m_tree.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 AxTree1.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:
axTree1.Items.set_CellHasCheckBox(axTree1.Items.FocusItem, 0, true); axTree1.Items.set_CellState(axTree1.Items.FocusItem, 0, 1);
The following VFP sample adds a check box that's checked to the focused cell:
with thisform.Tree1.Items .DefaultItem = .FocusItem .CellHasCheckBox( 0, 0 ) = .t. .CellState( 0,0 ) = 1 endwith
The following VB sample changes the state for a cell to checked state: Tree1.Items.CellState(Tree1.Items(0), 0) = 1,
The following VB sample changes the state for a cell to to unchecked state: Tree1.Items.CellState(Tree1.Items(0), 0) = 0,
The following VB sample changes the state for a cell to partial checked state: Tree1.Items.CellState(Tree1.Items(0), 0) = 2
The following VB sample displays a message when a cell of radio or check type is changing its state:
Private Sub Tree1_AddItem(ByVal Item As EXTREELibCtl.HITEM) Tree1.Items.CellHasCheckBox(Item, 0) = True End Sub Private Sub Tree1_CellStateChanged(ByVal Item As EXTREELibCtl.HITEM, ByVal ColIndex As Long) Debug.Print "The cell """ & Tree1.Items.CellCaption(Item, ColIndex) & """ has changed its state. The new state is " & IIf(Tree1.Items.CellState(Item, ColIndes) = 0, "Unchecked", "Checked") End Sub
Note: A cell is identified by the intersection of an item and a column. Properties that have Item and ColIndex parameters let you specify a cell in different ways. The Item parameter identifies the item, while the ColIndex parameter identifies the column.
The Item parameter can be the handle of an item. The ColIndex parameter can specify the column by its index (a numerical value, see the Column.Index property), by its caption (a string value, see the Column.Caption property), or by a cell handle returned by the ItemCell property.
For example, the following statement sets the Bold property of the cell at the intersection of the first item and the first column. The Item parameter is omitted because the ColIndex parameter receives the cell handle returned by ItemCell.
Tree1.Items.CellBold(, Tree1.Items.ItemCell(Tree1.Items(0), 0)) = True
The same cell can be specified by passing the item handle and the column index separately:
Tree1.Items.CellBold(Tree1.Items(0), 0) = True
You can also specify the column by its caption instead of its numerical index:
Tree1.Items.CellBold(Tree1.Items(0), "ColumnName") = True