

| Type | Description | |||
| Long | A long expression that indicates the index of the inner cell that's focused or selected. |
The control fires the FocusChanged event when the user changes:
The following VB sample determines the focused cell:
Private Sub Grid1_FocusChanged()
With Grid1
Dim hFocusCell As EXGRIDLibCtl.HCELL
hFocusCell = .Items.ItemCell(.Items.FocusItem, .FocusColumnIndex)
Debug.Print "Focus = " & .Items.CellCaption(, hFocusCell) & " (" & hFocusCell & ")"
End With
End Sub
The following VB sample determines the focused cell, if the control contains inner cells:
Private Sub Grid1_FocusChanged()
With Grid1
Dim hFocusCell As EXGRIDLibCtl.HCELL
hFocusCell = .Items.ItemCell(.Items.FocusItem, .FocusColumnIndex)
If (.SelectColumnInner > 0) Then
' Do we selected an inner cell?
hFocusCell = .Items.InnerCell(, hFocusCell, .SelectColumnInner)
End If
Debug.Print "Focus = " & .Items.CellCaption(, hFocusCell) & " (" & hFocusCell & ")"
End With
End SubThe following C++ sample displays the focused cell:
#include "Items.h"
void OnFocusChangedGrid1()
{
if ( IsWindow( m_grid.m_hWnd ) )
{
CItems items = m_grid.GetItems();
COleVariant vtItem( items.GetFocusItem() ), vtColumn( m_grid.GetFocusColumnIndex() );
CString strFormat;
strFormat.Format( "Focus on '%s'", V2S( &items.GetCellValue( vtItem, vtColumn ) ) );
OutputDebugString( strFormat );
}
}The following C++ sample displays the focused cell, if the control contains inner cells:
#include "Items.h"
void OnFocusChangedGrid1()
{
if ( IsWindow( m_grid.m_hWnd ) )
{
CItems items = m_grid.GetItems();
COleVariant vtMissing; V_VT( &vtMissing) = VT_ERROR;
COleVariant vtFocusCell( items.GetItemCell( items.GetFocusItem(), COleVariant(m_grid.GetFocusColumnIndex())));
if ( m_grid.GetSelectColumnInner() > 0 )
vtFocusCell = items.GetInnerCell( vtMissing, vtFocusCell, COleVariant(m_grid.GetSelectColumnInner()));
CString strFormat;
strFormat.Format( "Focus on '%s'", V2S( &items.GetCellValue( vtMissing, vtFocusCell ) ) );
OutputDebugString( strFormat );
}
}The following VB.NET sample displays the focused cell:
Private Sub AxGrid1_FocusChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxGrid1.FocusChanged
With AxGrid1.Items
Debug.Print("Focus on '" & .CellValue(.FocusItem, AxGrid1.FocusColumnIndex()).ToString() & "'")
End With
End SubThe following VB.NET sample displays the focused cell, if the control contains inner cells:
Private Sub AxGrid1_FocusChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxGrid1.FocusChanged
With AxGrid1.Items
Dim focusCell As Object = .ItemCell(.FocusItem, AxGrid1.FocusColumnIndex)
If (AxGrid1.SelectColumnInner > 0) Then
focusCell = .InnerCell(Nothing, focusCell, AxGrid1.SelectColumnInner)
End If
Debug.Print("Focus on '" & .CellValue(Nothing, focusCell).ToString() & "'")
End With
End SubThe following C# sample displays the focused cell:
private void axGrid1_FocusChanged(object sender, EventArgs e)
{
object focusValue = axGrid1.Items.get_CellValue(axGrid1.Items.FocusItem, axGrid1.FocusColumnIndex);
System.Diagnostics.Debug.WriteLine("Focus on '" + (focusValue != null ? focusValue.ToString() : "" ) + "'");
}The following C# sample displays the focused cell, if the control contains inner cells:
private void axGrid1_FocusChanged(object sender, EventArgs e)
{
object focusCell = axGrid1.Items.get_ItemCell(axGrid1.Items.FocusItem, axGrid1.FocusColumnIndex);
if ( axGrid1.SelectColumnInner > 0 )
focusCell = axGrid1.Items.get_InnerCell( null, focusCell, axGrid1.SelectColumnInner );
object focusValue = axGrid1.Items.get_CellValue(null, focusCell);
System.Diagnostics.Debug.WriteLine("Focus on '" + (focusValue != null ? focusValue.ToString() : "" ) + "'");
}The following VFP sample displays the focused cell:
*** ActiveX Control Event *** with thisform.Grid1.Items .DefaultItem = .FocusItem wait window nowait .CellCaption( 0, thisform.Grid1.FocusColumnIndex() ) endwith