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

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

 TypeDescription 
   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.

Once the user clicks a check-box, radio-button, the control fires the following events:

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

With G2antt1.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_g2antt.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 AxG2antt1.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:

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

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

with thisform.G2antt1.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: G2antt1.Items.CellState(G2antt1.Items(0), 0) = 1, 

The following VB sample changes the state for a cell to to unchecked state: G2antt1.Items.CellState(G2antt1.Items(0), 0) = 0, 

The following VB sample changes the state for a cell to partial checked state: G2antt1.Items.CellState(G2antt1.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 G2antt1_AddItem(ByVal Item As EXG2ANTTLibCtl.HITEM)
    G2antt1.Items.CellHasCheckBox(Item, 0) = True
End Sub

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

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:

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

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