property Grid.SelectColumnInner as Long
Retrieves or sets a value that indicates the index of the inner cell that's selected.

 TypeDescription 
   Long A long expression that indicates the index of the inner cell that's focused or selected.   
Use the SelectColumnInner property to get the index of the inner cell that's selected or focused. The SelectColumnInner property may be greater than zero, if the control contains inner cells. The SplitCell method splits a cell in two cells ( creates an inner cell ). The newly created cell is called inner cell. Use the FocusColumnIndex property to retrieve the index of the column that has the focus. The FocusItem property indicates the focused item. The SelectColumnIndex property determines the index of the column that's selected when FullRowSelect property is False. Use the FocusColumnIndex and SelectColumnInner property to change the cell that has the focus inside. 

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 Sub

The 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 Sub

The 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 Sub

The 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

 


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