Type | Description | |||
Index as Long | A long expression that indicates the index ( into the selected items collection ) of selected item being accessed. | |||
Long | A long expression that indicates the index of the selected item. |
The control supports single or multiple selection, depends on SingleSel property. Use the SelectCount and SelectedItem properties to enumerate the collection of selected items. Use the SelectItem property to select or unselect 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. 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.
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