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 IsItemVisible property to check whether an item fits the control's client area. Use the ItemChild property to get the first child item. Use the ItemParent property to retrieve the handle of the parent item.

The following VB sample enumerates all visible items in the control's list: 

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

The following C++ sample enumerates all visible items in the control's list:

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

The following VB.NET sample enumerates all visible items in the control's list:

With AxComboBox1.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 C# sample enumerates all visible items in the control's list:

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

The following VFP sample all visible items in the control's list:

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