property Items.NextVisibleItem (Item as HITEM) as HITEM

Retrieves the handle of next visible item.

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

Use the NextVisibleItem property to access the visible items. The NextVisibleItem property retrieves 0 if there are no more visible items.  Use the FirstVisibleItem property to get the first visible item in the control's client area. Use the RootItem property to get the first visible item in the list. The NextSiblingItem property retrieves the next sibling of the item in the parent's child list. Use the IsItemVisible property to check whether an item fits the control's client area. Use the ItemPosition property to change the position of the item. Use the SortOrder property to sort a column.

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 VB sample enumerates all cells in the control, as they are listed:

With Grid1
    Dim nCols As Long
    nCols = .Columns.Count
    With .Items
        Dim h As HITEM
        h = .RootItem(0)
        While Not h = 0
            Dim i As Long
            For i = 0 To nCols - 1
                Debug.Print .CellValue(h, i)
            Next
            h = .NextVisibleItem(h)
        Wend
    End With
End With

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