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 handle of the last visible item.

To get the first visible item use FirstVisibleItem property. The LastVisibleItem property retrieves the handle for the last visible item. 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 following VB sample enumerates the items that fit the control's client area:

On Error Resume Next
Dim h As HITEM
Dim i As Long, j As Long, nCols As Long
nCols = G2antt1.Columns.Count
With G2antt1.Items
    h = .FirstVisibleItem
    While Not (h = 0) And .IsItemVisible(h)
        Dim s As String
        s = ""
        For j = 0 To nCols - 1
            s = s + .CellValue(h, j) + Chr(9)
        Next
        Debug.Print s
        h = .NextVisibleItem(h)
    Wend
End With

The following C++ sample enumerates the items that fit the control's client area:

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

The following VB.NET sample enumerates the items that fit the control's client area:

With AxG2antt1.Items
    Dim hItem As Integer
    hItem = .FirstVisibleItem
    While Not (hItem = 0)
        If (.IsItemVisible(hItem)) Then
            Debug.Print(.CellValue(hItem, 0))
            hItem = .NextVisibleItem(hItem)
        Else
            Exit While
        End If
    End While
End With

The following C# sample enumerates the items that fit the control's client area:

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

The following VFP sample enumerates the items that fit the control's client area:

with thisform.G2antt1.Items
	.DefaultItem = .FirstVisibleItem
	do while ( ( .DefaultItem <> 0 ) and ( .IsItemVisible( 0 ) ) )
		wait window .CellValue( 0, 0 )
		.DefaultItem = .NextVisibleItem( 0 )	
	enddo
endwith