method Items.EnsureVisibleItem (Item as HITEM)

Ensures that the given item is in the visible client area.

TypeDescription
Item as HITEM A long expression that indicates the item's handle.

The EnsureVisibleItem scrolls the control's content until the item fits the visible client area. The EnsureVisibleItem method expands the parent items. Use the IsItemVisible property to check if an item fits the control's client area. Use the EnsureVisibleColumn method to scroll the control's content so a column fits the control's client area. Use the Scroll method to scroll the control's client area by code. The EnsureVisibleItem method should not be called during BeginUpdate and EndUpdate methods. The EnsureOnSort property prevents scrolling the control's content when the user sorts items.

The following VB sample ensures that the last added item fits the control's client area:

With Grid1.Items
  .EnsureVisibleItem .ItemByIndex(.ItemCount - 1)
End With

The following C++ sample ensures that the last added item fits the control's client area:

#include "Items.h"
m_grid.BeginUpdate();
CItems items = m_grid.GetItems();
items.EnsureVisibleItem( items.GetItemByIndex( items.GetItemCount() - 1 ) );

The following VB.NET sample ensures that the last added item fits the control's client area:

With AxGrid1.Items
    .EnsureVisibleItem(.ItemByIndex(.ItemCount - 1))
End With

The following C# sample ensures that the last added item fits the control's client area:

axGrid1.Items.EnsureVisibleItem(axGrid1.Items[axGrid1.Items.ItemCount - 1]);

The following VFP sample ensures that the last added item fits the control's client area:

with thisform.Grid1.Items
	.EnsureVisibleItem(.ItemByIndex(.ItemCount-1))
endwith