Type | Description | |||
Index as Long | A long expression that indicates the index of the item. |
Use the Remove method to remove a specific item. The Remove method updates the indexes of the items in the list. For instance, if you remove the item 0, the items 1, 2, 3, ... becomes the 0,1,2,... Use the RemoveAll method to clear the Items collection. The control fires the RemoveItem event before removing an item. Use the RemoveItem event to release any extra data associated to the item. The Remove method is not available if the control is running in the virtual mode. Use the BeginUpdate and EndUpdate methods to maintain performance while removing items. Use the CellState property to specify whether an item is checked or unchecked. Use the SelectedItem property to retrieve the index of selected item(s). The RemoveSelection method removes the selected items
The following VB sample removes all selected items:
With List1 .BeginUpdate With .Items While .SelectCount > 0 .Remove .SelectedItem(0) Wend End With .EndUpdate End With
The following VB sample removes the checked items:
With List1 .BeginUpdate With .Items Dim i As Long For i = .Count - 1 To 0 Step -1 If .CellState(i, 0) Then .Remove i End If Next End With .EndUpdate End With
or you can use a sample like follows:
With List1 .BeginUpdate With .Items Dim i As Long i = 0 While i < .Count If (.CellState(i, 0)) Then .Remove (i) Else i = i + 1 End If Wend End With .EndUpdate End With
The following C++ sample removes the selected items:
#include "Items.h" m_list.BeginUpdate(); CItems items = m_list.GetItems(); while ( items.GetSelectCount() ) items.Remove(items.GetSelectedItem(0)); m_list.EndUpdate();
The following VFP sample removes the selected items:
with thisform.List1 .BeginUpdate() with .Items do while ( .SelectCount() > 0 ) .Remove(.SelectedItem(0)) enddo endwith .EndUpdate() endwith