property Items.SelectCount as Long
Retrieves the count of selected items.

TypeDescription
Long A long expression that indicates the count of the selected items.

The control supports single or multiple selection.  Use the SelectCount and SelectedItem properties to enumerate the collection of selected items. Use the SelectItem property to select or unselects programmatically an item. The SelectionChanged event is fired when the user changes the selection. Use the SelForeColor and SelBackColor properties to specify colors for selected items. Use the SingleSel property of the control to allow multiple selection. If the control supports only single selection ( SingleSel property is True ), the FocusItem retrieves the selected item too. Use the Caption property to specify the cell's caption. Use the SelectAll method to select all items in the list. Use the UnselectAll method to unselect all items in the list.

The following VB sample enumerates the collection of selected items:

Dim i As Long
With List1.Items
    For i = 0 To .SelectCount() - 1
        Debug.Print .Caption(.SelectedItem(i), 0)
    Next
End With

The following C++ sample enumerates the collection of selected items:

CItems items = m_list.GetItems();
for ( long i = 0; i < items.GetSelectCount(); i++ )
{
	CString strCaption = V2S( &items.GetCaption( items.GetSelectedItem(i), COleVariant( long(0) ) ) );
	OutputDebugString( strCaption );
}

The following VB.NET sample enumerates the collection of selected items:

With AxList1.Items
    Dim i As Integer
    For i = 0 To .SelectCount() - 1
        Debug.WriteLine(.Caption(.SelectedItem(i), 0))
    Next
End With

The following C# sample enumerates the collection of selected items:

for ( int i = 0; i < axList1.Items.SelectCount; i++ )
{
	object cell = axList1.Items.get_Caption(axList1.Items.get_SelectedItem(i), 0);
	System.Diagnostics.Debug.WriteLine(cell != null ? cell.ToString() : "");
}

The following VFP sample enumerates the collection of selected items:

local i
With thisform.List1.Items
    For i = 0 To .SelectCount() - 1
        wait window nowait .Caption(.SelectedItem(i), 0)
    Next
EndWith