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

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

 TypeDescription 
   Item as Variant A long expression that indicates the item's handle.  
   ColIndex as Variant A long expression that indicates 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.  

To change the state for a check cell you have to use CellState property. 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. To set the cell of radio type you have call CellHasRadioButton  property. 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 PartialCheck property to allow partial check feature within the column. Use the CheckImage property to change the check box appearance. Use the FilterType property on exCheck to filter for checked or unchecked items.

The following sample enumerates the cells in the first column and assign a checkbox to all of them:

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

The same thing we can do using the Def property like follows:

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

The following sample shows how how set the type of cells to radio type while adding new items:

Private Sub Tree1_AddItem(ByVal Item As EXTREELibCtl.HITEM)
    Tree1.Items.CellHasCheckBox(Item, 0) = True
End Sub

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

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

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

With Tree1.Items
    .CellHasCheckBox(.FocusItem, 0) = True
End With

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

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

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

axTree1.Items.set_CellHasCheckBox(axTree1.Items.FocusItem, 0, true);

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

With AxTree1.Items
    .CellHasCheckBox(.FocusItem, 0) = True
End With

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

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

Note: A cell is the intersection of an item with a column. All properties that has an Item and a ColIndex parameters are referring to a cell. The Item parameter represents the handle of an item, and the ColIndex parameter indicates an index ( a numerical value, see Column.Index property ) of a column , the column's caption ( a string value, see Column.Caption property ), or a handle to a cell. Here's few hints how to use properties with Item and ColIndex parameters:

Tree1.Items.CellBold(, Tree1.Items.ItemCell(Tree1.Items(0), 0)) = True
Tree1.Items.CellBold(Tree1.Items(0), 0) = True
Tree1.Items.CellBold(Tree1.Items(0), "ColumnName") = True

Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.