property Items.LastVisibleItem ([Partially as Variant]) as HITEM

Retrieves the handle of the last visible item.

TypeDescription
Partially as Variant A boolean expression that indicates whether the item is partially visible. By default, the Partially parameter is False.
HITEM A long expression that indicates the item's handle that indicates the last visible item.

The LastVisibleItem property retrieves the handle for the last visible item. To get the first visible item use FirstVisibleItem property. Use the FirstVisibleItem, NextVisibleItem and IsItemVisible properties to get the items that fit the client area. Use the NextVisibleItem property to get the next visible item. Use the IsVisibleItem property to check whether an item fits the control's client area. The LastVisibleItem(False) property gets the handle of the last visible item that's not a partial item. The LastVisibleItem(True) property gets the handle of the last visible item no matter if it is partially visible or not. 

The following VB sample enumerates all visible items:

Private Sub VisItems(ByVal c As EXGRIDLibCtl.Grid)
    Dim h As HITEM
    With c.Items
        h = .FirstVisibleItem
        While Not (h = 0)
            Debug.Print .CellCaption(h, 0)
            h = .NextVisibleItem(h)
        Wend
    End With
End Sub

The following C++ sample enumerates all visible items:

#include "Items.h"
CItems items = m_grid.GetItems();
long hItem = items.GetFirstVisibleItem();
while ( hItem )
{
	OutputDebugString( V2S( &items.GetCellValue( COleVariant( hItem ), COleVariant( long(0) ) ) ) );
	hItem = items.GetNextVisibleItem( hItem );
}

The following C# sample enumerates all visible items:

EXGRIDLib.Items items = axGrid1.Items;
int hItem = items.FirstVisibleItem;
while (hItem != 0)
{
	object strCaption = items.get_CellValue(hItem, 0);
	System.Diagnostics.Debug.WriteLine(strCaption != null ? strCaption.ToString() : "");
	hItem = items.get_NextVisibleItem(hItem);
}

The following VB.NET sample enumerates all visible items:

With AxGrid1.Items
    Dim hItem As Integer
    hItem = .FirstVisibleItem
    While Not (hItem = 0)
        Debug.Print(.CellCaption(hItem, 0))
        hItem = .NextVisibleItem(hItem)
    End While
End With

The following VFP sample enumerates all visible items:

with thisform.Grid1.Items
	.DefaultItem = .FirstVisibleItem
	do while ( .DefaultItem <> 0 ) 
		wait window .CellCaption( 0, 0 )
		.DefaultItem = .NextVisibleItem( 0 )	
	enddo
endwith