Removes a specific item.
Type | Description | |||
Item as HITEM | A long expression that indicates the handle of the item being removed. |
The RemoveItem method removes an item. The RemoveItem method does not remove the item, if it contains child items. The following sample removes the first item: Tree1.Items.RemoveItem Tree1.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. The RemoveSelection method removes the selected items (including the descendents).
The following VB sample removes recursively an item:
Private Sub RemoveItemRec(ByVal t As EXTREELibCtl.Tree, 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( CTree* pTree, long hItem ) { if ( hItem ) { pTree->BeginUpdate(); CItems items = pTree->GetItems(); long hChild = items.GetItemChild( hItem ); while ( hChild ) { long nNext = items.GetNextSiblingItem( hChild ); RemoveItemRec( pTree, hChild ); hChild = nNext; } items.RemoveItem( hItem ); pTree->EndUpdate(); } }
The following VB.NET sample removes recursively an item:
Shared Sub RemoveItemRec(ByVal t As AxEXTREELib.AxTree, 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(AxEXTREELib.AxTree tree, int hItem) { if (hItem != 0) { EXTREELib.Items items = tree.Items; tree.BeginUpdate(); int hChild = items.get_ItemChild(hItem); while (hChild != 0) { int hNext = items.get_NextSiblingItem(hChild); RemoveItemRec(tree, hChild); hChild = hNext; } items.RemoveItem(hItem); tree.EndUpdate(); } }
The following VFP sample removes recursively an item ( removeitemrec method ):
LPARAMETERS h with thisform.Tree1 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