property Items.CellChecked (RadioGroup as Long) as HCELL

Retrieves the handle of the cell that is checked, given the radio group identifier.

TypeDescription
RadioGroup as Long A long expression that indicates the radio group identifier.
HCELL A long expression that indicates the cell's handle. Use the CellItem property to retrieve the handle of the owner item.
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 Grid1_AddItem(ByVal Item As EXGRIDLibCtl.HITEM)
    Grid1.Items.CellHasRadioButton(Item, 0) = True
    Grid1.Items.CellRadioGroup(Item, 0) = 1234 ' The 1234 is arbirary and it represents the identifier for the radio group
End Sub

Private Sub Grid1_CellStateChanged(ByVal Item As EXGRIDLibCtl.HITEM, ByVal ColIndex As Long)
    Debug.Print "In the 1234 radio group the """ & Grid1.Items.CellValue(, Grid1.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_grid.GetItems();
m_grid.BeginUpdate();
for ( long i = 0; i < items.GetItemCount(); i++ )
{
	COleVariant vtItem( items.GetItemByIndex( i ) );
	items.SetCellHasRadioButton( vtItem, vtColumn, TRUE );
	items.SetCellRadioGroup( vtItem, vtColumn, 1234 );
}
m_grid.EndUpdate();
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 OnCellStateChangedGrid1(long Item, long ColIndex) 
{
	CItems items = m_grid.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 AxGrid1
    .BeginUpdate()
    With .Items
        Dim k As Integer
        For k = 0 To .ItemCount - 1
            .CellHasRadioButton(.ItemByIndex(k), 0) = True
            .CellRadioGroup(.ItemByIndex(k), 0) = 1234
        Next
    End With
    .EndUpdate()
End With
Private Sub AxGrid1_CellStateChanged(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_CellStateChangedEvent) Handles AxGrid1.CellStateChanged
    With AxGrid1.Items
        Debug.WriteLine(.CellCaption(, .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:

axGrid1.BeginUpdate();
EXGRIDLib.Items items = axGrid1.Items;
for (int i = 0; i < items.ItemCount; i++)
{
	items.set_CellHasRadioButton(items[i], 0, true);
	items.set_CellRadioGroup(items[i], 0, 1234);
}
axGrid1.EndUpdate();
private void axGrid1_CellStateChanged(object sender, AxEXGRIDLib._IGridEvents_CellStateChangedEvent e)
{
	string strOutput = axGrid1.Items.get_CellCaption( 0, axGrid1.Items.get_CellChecked(1234) ).ToString();
	strOutput += " state = " + axGrid1.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:

thisform.Grid1.BeginUpdate()
with thisform.Grid1.Items
	local i
	for i = 0 to .ItemCount - 1
		.DefaultItem = .ItemByIndex(i)
		.CellHasRadioButton( 0,0 ) = .t.
		.CellRadioGroup(0,0) = 1234
	next
endwith
thisform.Grid1.EndUpdate()

Note : The intersection of an item with a column defines a cell. Each cell is uniquely represented by its handle. The cell's handle is of HCELL type. All properties of Items object that have two parameters Item and ColIndex, refer a cell.

The following lines are equivalents and each of them changes the bold font attribute of the first cell on the first item.

With Grid1
    .Items.CellBold(, .Items.ItemCell(.Items(0), 0)) = True
    .Items.CellBold(.Items(0), 0) = True
    .Items.CellBold(.Items(0)) = True
    .Items.CellBold(.Items.ItemByIndex(0)) = True
    .Items.CellBold(.Items.ItemByIndex(0), 0) = True
    .Items.CellBold(.Items(0), Grid1.Columns(0).Caption) = True
End With