property Items.CellHasCheckBox([Item as Variant], [ColIndex as Variant]) as Boolean

Retrieves or sets a value indicating whether the cell has an associated checkbox.

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.
Boolean A boolean expression that indicates whether the cell contains a check box button.

Use the CellState property to change the state of the cell of the check box type. The cell cannot display in the same time a radio and a check button. The control fires CellStateChanged  event when the cell's state has been changed. Use the  CellHasRadioButton  property to add a radio button to your cell. Use the PartialCheck property to enable partial check feature. The CheckImage property specifies the icon being displayed for different check box states. The EditType.CheckValueType value specifies whether the editor displays a check box to represent the cell's value. Use the Def property to assign check boxes for all cells in the column. Use the CellImage property to add a single icon to a cell. Use the CellImages property to assign multiple icons to a cell. Use the CellPicture property to load a custom size picture to a cell. Use the FilterType property on exCheck to filter for checked or unchecked items.  Use the Def(exCellDrawPartsOrder) property to specify the order of the drawing parts inside the cell.

The following VB sample assigns a checkbox to all cells in the first column:

 With Grid1.Columns(0)
    .Def(exCellHasCheckBox) = True
End With

The following VB sample assigns a checkbox to all cells in the first column:

Dim h As Variant
Grid1.BeginUpdate
With Grid1.Items
For Each h In Grid1.Items
    .CellHasCheckBox(h) = True
Next
End With
Grid1.EndUpdate

The following VB sample uses the AddItem event to add a check box for all cells in the first column:

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

The VB following sample uses the CellStateChanged event to display a message when a cell of radio or check type has changed its state:

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

The EditType.CheckValueType value specifies whether the editor displays a check box to represent the cell's value. For instance, if you have a column of boolean values, you can use the following VB code to assign check boxes to each cell in the column:

With Grid1.Columns("Check").Editor
        .EditType = CheckValueType
End With

In this case, the CellValue property for each cell in the column specifies the state of the check box as follows:

If the values in the column differs than 0, 1, or 2 you can call the Editor.Option/DefaultEditorOption property to specify the check box states being displayed.  For instance, if your column contains boolean values, True ( -1 ) and False ( 0 ), you can use the following sample to get displayed the checked states instead partial checked states.

With Grid1.Columns("Check").Editor
        .EditType = CheckValueType
        .Option(exCheckValue2) = 1
End With

The following VB sample adds a checkbox to the focused cell:

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

The following C++ sample adds a checkbox to the focused cell:

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

The following C# sample adds a checkbox to the focused cell:

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

The following VB.NET sample adds a checkbox to the focused cell:

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

The following VFP sample adds a checkbox to the focused cell:

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

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