property Items.Selection as Variant
Selects items by index.

TypeDescription
Variant A long expression that indicates the index of item being selected, if the SingleSel property is True, or a safe array that holds a collection of index of items being selected, if the SingleSel property is False.
The Selection property selects/unselects items by index. Use the SelectItem property to select an item giving its handle. The ItemPosition property gives the relative position, or the position of the item in the child items collection. Use the SelectPos property to select items by position. The SelectPos property selects an item giving its general position.  

The SingleSel property specifies whether the control supports single or multiple-selection. Based on the SingleSel property the Selection value is:

The following VB sample selects the item with the index 0 in the control / SingleSel property is True ( by default ):

Grid1.Items.Selection = 0

The following VB sample selects the item with the index 0 and 1 in the control / SingleSel property is False:

Grid1.Items.Selection = Array(0, 1)

The following C++ sample selects the item with the index 0 in the control / SingleSel property is True ( by default ):

m_grid.GetItems().SetSelection( COleVariant( long(0) ) );

The following C++ sample selects the item with the index 0 in the control / SingleSel property is False:

CArray<long> a;
a.Add( 0 );
a.Add( 1 );
m_spExGrid->Items->Selection = CreateSafeArray( a );

where the CreateSafeArray looks as:

CComVariant CreateSafeArray(CArray<long>& a)
{
	CComVariant vtResult;

	long nCount = a.GetCount();
	if ( SAFEARRAY* pArray = SafeArrayCreateVector( VT_VARIANT, 0, nCount ) )
	{
		LPVOID pData = NULL;
		SafeArrayAccessData( pArray, &pData );
		VARIANT* p = (VARIANT*)pData;
		for ( long i = 0; i < nCount; p++, i++ )
		{
			ZeroMemory( p, sizeof( VARIANT ) );
			V_VT( p ) = VT_I4;
			V_I4( p ) = a.GetAt( i );
		}
		SafeArrayUnaccessData( pArray );

		V_VT( &vtResult ) = VT_ARRAY | VT_VARIANT;
		V_ARRAY( &vtResult ) = pArray;
	}
	return vtResult;
}

The following VB.NET sample selects the item with the index 0 in the control / SingleSel property is True ( by default ):

With AxGrid1.Items
    .Selection = 0
End With

The following C# sample selects the item with the index 0 in the control / SingleSel property is True ( by default ):

axGrid1.Items.Selection = 0;

The following VFP sample selects the item with the index 0 in the control / SingleSel property is True ( by default ):

with thisform.Grid1.Items
	.Selection = 0
endwith