Removes the given item.
Type | Description | |||
Item as HITEM | A long expression that indicates the item's handle being removed. |
The RemoveItem method removes an item. The RemoveItem method does not remove the item, if it contains child items. The RemoveSelection method removes the selected items (including the descendents). The following sample removes the first item: ComboBox1.Items.RemoveItem ComboBox1.Items(0). Use the RemoveAllItems method to remove all items in the control. Use the BeginUpdate and EndUpdate methods to maintain performance while removing the items. The RemoveItem method can't remove an item that's locked. Instead you can use the LockedItemCount property to add or remove locked items. Use the IsItemLocked property to check whether an item is locked. If the Style property is DropDown, you can use the EditText property to specify the text in the control's label area after removing an item.
The following VB sample removes recursively an item:
Private Sub RemoveItemRec(ByVal t As EXCOMBOBOXLibCtl.ComboBox, ByVal h As HITEM) If Not h = 0 Then With t.Items t.BeginUpdate Dim hChild As HITEM hChild = .ItemChild(h) While (hChild <> 0) Dim hNext As HITEM hNext = .NextSiblingItem(hChild) RemoveItemRec t, hChild hChild = hNext Wend .RemoveItem h t.EndUpdate End With End If End Sub
The following C++ sample removes recursively an item:
void RemoveItemRec( CComboBox* pComboBox, long hItem ) { if ( hItem ) { pComboBox->BeginUpdate(); CItems items = pComboBox->GetItems(); long hChild = items.GetItemChild( hItem ); while ( hChild ) { long nNext = items.GetNextSiblingItem( hChild ); RemoveItemRec( pComboBox, hChild ); hChild = nNext; } items.RemoveItem( hItem ); pComboBox->EndUpdate(); } }
The following VB.NET sample removes recursively an item:
Shared Sub RemoveItemRec(ByVal t As AxEXCOMBOBOXLib.AxComboBox, ByVal h As Integer) If Not h = 0 Then With t.Items t.BeginUpdate() Dim hChild As Integer = .ItemChild(h) While (hChild <> 0) Dim hNext As Integer = .NextSiblingItem(hChild) RemoveItemRec(t, hChild) hChild = hNext End While .RemoveItem(h) t.EndUpdate() End With End If End Sub
The following C# sample removes recursively an item:
internal void RemoveItemRec(AxEXCOMBOBOXLib.AxComboBox combobox, int hItem) { if (hItem != 0) { EXCOMBOBOXLib.Items items = combobox.Items; combobox.BeginUpdate(); int hChild = items.get_ItemChild(hItem); while (hChild != 0) { int hNext = items.get_NextSiblingItem(hChild); RemoveItemRec(combobox, hChild); hChild = hNext; } items.RemoveItem(hItem); combobox.EndUpdate(); } }
The following VFP sample removes recursively an item ( removeitemrec method ):
LPARAMETERS h with thisform.ComboBox1 If ( h != 0 ) Then .BeginUpdate() local hChild With .Items hChild = .ItemChild(h) do While (hChild != 0) local hNext hNext = .NextSiblingItem(hChild) thisform.removeitemrec(hChild) hChild = hNext enddo .RemoveItem( h ) EndWith .EndUpdate() EndIf endwith