event CellStateChanged (Cell as HCELL)

Fired after cell's state has been changed.

 TypeDescription 
   Cell as HCELL A long expression that indicates the handle of the cell whose state is changed.  

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 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 ComboBox1_CellStateChanged(ByVal Cell As EXCOMBOBOXLibCtl.HCELL)
    With ComboBox1.Items
        Debug.Print "The cell """ & .CellCaption(, Cell) & """ has changed its state. The new state is " & IIf(.CellState(, Cell) = 0, "Unchecked", "Checked")
    End With
End Sub

The following VC sample displays the caption of the cell whose checkbox's state is changed:

#include "Items.h"
static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}
void OnCellStateChangedCombobox1(long Cell) 
{
	if ( ::IsWindow( m_combobox.m_hWnd ) )
	{
		CItems items = m_combobox.GetItems();
		COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
		COleVariant vtCell( Cell );
		CString strCellCaption = V2S( &items.GetCellCaption( vtMissing, vtCell ) );
		CString strOutput;
		strOutput.Format( "'%s''s checkbox state is %i\r\n", strCellCaption, items.GetCellState( vtMissing, vtCell ) );
		OutputDebugString( strOutput );
	}
}

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

Private Sub AxComboBox1_CellStateChanged(ByVal sender As Object, ByVal e As AxEXCOMBOBOXLib._IComboBoxEvents_CellStateChangedEvent) Handles AxComboBox1.CellStateChanged
    With AxComboBox1.Items
        Debug.Print("The cell """ & .CellCaption(, e.cell) & """ has changed its state. The new state is " & IIf(.CellState(, e.cell) = 0, "Unchecked", "Checked"))
    End With
End Sub

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

private void axComboBox1_CellStateChanged(object sender, AxEXCOMBOBOXLib._IComboBoxEvents_CellStateChangedEvent e)
{
	string strOutput = axComboBox1.Items.get_CellCaption(null, e.cell).ToString();
	strOutput += " state = " + axComboBox1.Items.get_CellState(null, e.cell).ToString();
	System.Diagnostics.Debug.WriteLine(strOutput);
}

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

*** ActiveX Control Event ***
LPARAMETERS cell

local sOutput
sOutput = ""
with thisform.ComboBox1.Items
	.DefaultItem = .CellItem(cell)
	sOutput = .CellCaption( 0, 0 )
	sOutput = sOutput + ", state = " + str(.CellState( 0, 0 ))
	wait window nowait sOutput
endwith


Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.