property Items.CellChecked (RadioGroup as Long) as HCELL

Retrieves the cell's handle that is checked on a specific radio group.

   RadioGroup as Long A long expression that indicates the radio group identifier.  
   HCELL A long expression that identifies the handle of the cell that's checked in the specified radio group. To retrieve the handle of the owner item you have to use CellItem property.  

A radio group contains a set of cells of radio types. Use the CellHasRadioButton property to set the cell of radio type. To change the state for a cell you can use the CellState property. To add or remove a cell to a given radio group you have to use CellHasRadioButton property. Use the CellRadioGroup property to add cells in the same radio group. The control fires the CellStateChanged event when the check box or radio button state is changed.

The following VB sample groups all cells on the first column into a radio group, and display the cell's checked on the radio group when the state of a radio group is changed:

Private Sub G2antt1_AddItem(ByVal Item As EXG2ANTTLibCtl.HITEM)
    G2antt1.Items.CellHasRadioButton(Item, 0) = True
    G2antt1.Items.CellRadioGroup(Item, 0) = 1234 ' The 1234 is arbirary and it represents the identifier for the radio group
End Sub

Private Sub G2antt1_CellStateChanged(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long)
    Debug.Print "In the 1234 radio group the """ & G2antt1.Items.CellValue(, G2antt1.Items.CellChecked(1234)) & """ is checked."
End Sub

The following C++ sample groups the radio cells on the first column, and displays the caption of the checked radio cell:

#include "Items.h"
COleVariant vtColumn( long(0) );
CItems items = m_g2antt.GetItems();
for ( long i = 0; i < items.GetItemCount(); i++ )
	COleVariant vtItem( items.GetItemByIndex( i ) );
	items.SetCellHasRadioButton( vtItem, vtColumn, TRUE );
	items.SetCellRadioGroup( vtItem, vtColumn, 1234 );
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();
	long hCell = items.GetCellChecked( 1234 );
	COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
	OutputDebugString( V2S( &items.GetCellValue( vtMissing, COleVariant( hCell ) ) ) );

The following VB.NET sample groups the radio cells on the first column, and displays the caption of the checked radio cell:

With AxG2antt1
    With .Items
        Dim k As Integer
        For k = 0 To .ItemCount - 1
            .CellHasRadioButton(.ItemByIndex(k), 0) = True
            .CellRadioGroup(.ItemByIndex(k), 0) = 1234
    End With
End With
Private Sub AxG2antt1_CellStateChanged(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent) Handles AxG2antt1.CellStateChanged
    With AxG2antt1.Items
        Debug.WriteLine(.CellValue(, .CellChecked(1234)))
    End With
End Sub

The following C# sample groups the radio cells on the first column, and displays the caption of the checked radio cell:

EXG2ANTTLib.Items items = axG2antt1.Items;
for (int i = 0; i < items.ItemCount; i++)
	items.set_CellHasRadioButton(items[i], 0, true);
	items.set_CellRadioGroup(items[i], 0, 1234);
private void axG2antt1_CellStateChanged(object sender, AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent e)
	string strOutput = axG2antt1.Items.get_CellValue( 0, axG2antt1.Items.get_CellChecked(1234) ).ToString();
	strOutput += " state = " + axG2antt1.Items.get_CellState(e.item, e.colIndex).ToString() ;
	System.Diagnostics.Debug.WriteLine( strOutput );

The following VFP sample groups the radio cells on the first column, and displays the caption of the checked radio cell:

with thisform.G2antt1.Items
	local i
	for i = 0 to .ItemCount - 1
		.DefaultItem = .ItemByIndex(i)
		.CellHasRadioButton( 0,0 ) = .t.
		.CellRadioGroup(0,0) = 1234

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 ( see ItemCell property ). 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-2018 Exontrol.COM, Software. All rights reserved.