method Grid.EnsureVisibleColumn (Column as Variant)
Scrolls the control's content to ensure that the column fits the client area.

TypeDescription
Column as Variant A long expression that indicates the column's index being scrolled, or a string expression that indicates the column's caption or the column's key. 

This method ensures that a column is at least partially visible. The control scrolls the content if necessary. The control automatically calls EnsureVisibleColumn method when the user clicks a cell in the column. Use the EnsureVisibleItem method to ensure that a specified item fits the control's client area. Use the ScrollBars property to hide the control's scroll bars. Use the Scroll method to programmatically scroll the control's content.

The following VB sample changes the searching column when user clicks a cell:

Private Sub Grid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With Grid1
        Dim c As Long, hit as Long
        Dim h As HITEM
        h = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit)
        If Not (h = 0) Then
            .SearchColumnIndex = c
        End If
    End With
End Sub

The following VB sample ensures that a hidden column is going visible, and fits the control's client area:

With Grid1
    .Columns("G").Visible = True
    DoEvents
    .EnsureVisibleColumn ("G")
End With

The following C++ sample ensures that a hidden column is going visible, and fits the control's client area:

COleVariant vtColumn("G");
m_grid.GetColumns().GetItem( vtColumn ).SetVisible( TRUE );
DoEvents();
m_grid.EnsureVisibleColumn( vtColumn );

where an equivalent of DoEvents in C++ is:

void DoEvents()
{
	MSG m = {0};
	while ( PeekMessage( &m, NULL, NULL, NULL, PM_REMOVE ) )
	{
		TranslateMessage( &m );
		DispatchMessage( &m );
	}
}

Calling the DoEvents method it not required if before you are not changing the column's layout. Making a column visible or hidden changes the arrangement of the columns, that's processed later. The DoEvents method forces the control to arrange the column, before calling the EnsureVisibleColumn method.