event CellStateChanged (Item as HITEM, ColIndex as Long)

Fired after cell's state has been changed.

 TypeDescription 
   Item as HITEM A long expression that indicates the handle of the item where the cell's state is changed.   
   ColIndex as Long A long expression that indicates the index of the column where the cell's state is changed, or 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. The control fires the CellStateChanging event just before cell's state is about to be 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 Def property to assign check-boxes / radio-buttons for all cells in the column. 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.

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

Syntax for CellStateChanged event, /NET version, on:

private void CellStateChanged(object sender,int Item,int ColIndex)
{
}

Private Sub CellStateChanged(ByVal sender As System.Object,ByVal Item As Integer,ByVal ColIndex As Integer) Handles CellStateChanged
End Sub

Syntax for CellStateChanged event, /COM version, on:

private void CellStateChanged(object sender, AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent e)
{
}

void OnCellStateChanged(long Item,long ColIndex)
{
}

void __fastcall CellStateChanged(TObject *Sender,Exg2anttlib_tlb::HITEM Item,long ColIndex)
{
}

procedure CellStateChanged(ASender: TObject; Item : HITEM;ColIndex : Integer);
begin
end;

procedure CellStateChanged(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent);
begin
end;

begin event CellStateChanged(long Item,long ColIndex)
end event CellStateChanged

Private Sub CellStateChanged(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent) Handles CellStateChanged
End Sub

Private Sub CellStateChanged(ByVal Item As EXG2ANTTLibCtl.HITEM,ByVal ColIndex As Long)
End Sub

Private Sub CellStateChanged(ByVal Item As Long,ByVal ColIndex As Long)
End Sub

LPARAMETERS Item,ColIndex

PROCEDURE OnCellStateChanged(oG2antt,Item,ColIndex)
RETURN

Syntax for CellStateChanged event, /COM version (others), on:

<SCRIPT EVENT="CellStateChanged(Item,ColIndex)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function CellStateChanged(Item,ColIndex)
End Function
</SCRIPT>

Procedure OnComCellStateChanged HITEM llItem Integer llColIndex
	Forward Send OnComCellStateChanged llItem llColIndex
End_Procedure

METHOD OCX_CellStateChanged(Item,ColIndex) CLASS MainDialog
RETURN NIL

void onEvent_CellStateChanged(int _Item,int _ColIndex)
{
}

function CellStateChanged as v (Item as OLE::Exontrol.G2antt.1::HITEM,ColIndex as N)
end function

function nativeObject_CellStateChanged(Item,ColIndex)
return

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

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

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 OnCellStateChangedG2antt1(long Item, long ColIndex) 
{
	CItems items = m_g2antt.GetItems();
	COleVariant vtItem( Item ), vtColumn( ColIndex );
	CString strCellValue = V2S( &items.GetCellValue( vtItem, vtColumn ) );
	CString strOutput;
	strOutput.Format( "'%s''s checkbox state is %i\r\n", strCellValue, items.GetCellState( vtItem, vtColumn ) );
	OutputDebugString( strOutput );
}

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

Private Sub AxG2antt1_CellStateChanged(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent) Handles AxG2antt1.CellStateChanged
    Debug.WriteLine("The cell """ & AxG2antt1.Items.CellValue(e.item, e.colIndex) & """ has changed its state. The new state is " & IIf(AxG2antt1.Items.CellState(e.item, e.colIndex) = 0, "Unchecked", "Checked"))
End Sub

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

private void axG2antt1_CellStateChanged(object sender, AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent e)
{
	string strOutput = axG2antt1.Items.get_CellValue( e.item, e.colIndex ).ToString();
	strOutput += " state = " + axG2antt1.Items.get_CellState(e.item, e.colIndex).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 item, colindex

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



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