event CellStateChanged (Item as HITEM, ColIndex as Long)
Fired after cell's state has been changed.

 TypeDescription 
   Item as HITEM A long expression that determines the item's handle. If the Item parameter is 0, and the ColIndex property is different than zero, the ColIndex indicates the handle of the cell where the state is changed.  
   ColIndex as Long A long expression that indicates the column's index, if the Item parameter is not zero, a long expression that indicates the handle of the cell if the Item parameter is 0.  

A cell that contains a radio button or a check box button fires the CellStateChanged event when its state is changed. Use the CellState property to change the cell's state. Use the CellHasRadioButton or CellHasCheckBox property to enable radio or check box button into a cell. Use the CellImage property to display an icon in the cell. Use the CellImages property to display multiple icons in the same cell.  Use the PartialCheck property to enable partial check feature ( check boxes with three states: partial, checked and unchecked ). Use the CellChecked property to determine the handle of the cell that's checked in a radio group. Use the CellRadioGroup property to radio group cells

The following VB sample displays a message when the user clicks a check box or a radio button:

Private Sub Grid1_CellStateChanged(ByVal Item As EXGRIDLibCtl.HITEM, ByVal ColIndex As Long)
    With Grid1.Items
        Debug.Print "'" & .CellValue(Item, ColIndex) & "' = " & .CellState(Item, ColIndex)
    End With
End Sub

The following C++ sample displays a message when the user clicks a check box or a radio button:

#include "Items.h"
void OnCellStateChangedGrid1(long Item, long ColIndex) 
{
	CItems items = m_grid.GetItems();
	COleVariant vtItem( Item ), vtColumn( ColIndex );
	CString strFormat;
	strFormat.Format( "'%s' = %i", items.GetCellCaption( vtItem, vtColumn ), items.GetCellState( vtItem, vtColumn ) );
	OutputDebugString( strFormat );
}

The following VB.NET sample displays a message when the user clicks a check box or a radio button:

Private Sub AxGrid1_CellStateChanged(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_CellStateChangedEvent) Handles AxGrid1.CellStateChanged
    With AxGrid1.Items
        Debug.Print(.CellCaption(e.item, e.colIndex) & " = " & .CellState(e.item, e.colIndex).ToString())
    End With
End Sub

The following C# sample displays a message when the user clicks a check box or a radio button:

private void axGrid1_CellStateChanged(object sender, AxEXGRIDLib._IGridEvents_CellStateChangedEvent e)
{
	string strOutput = axGrid1.Items.get_CellCaption(e.item, e.colIndex).ToString();
	strOutput += " = " + axGrid1.Items.get_CellState(e.item, e.colIndex).ToString();
	System.Diagnostics.Debug.WriteLine(strOutput);
}

The following VFP sample displays a message when the user clicks a check box or a radio button:

*** ActiveX Control Event ***
LPARAMETERS item, colindex

local sOutput
sOutput = ""
with thisform.Grid1.Items
	.DefaultItem = item
	sOutput = .CellCaption( 0, colindex )
	sOutput = sOutput + ", state = " + str(.CellState( 0, colindex ))
	wait window nowait sOutput
endwith


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