TreeView_DeleteItem macro (commctrl.h)

Removes an item and all its children from a tree-view control. You can also send the TVM_DELETEITEM message explicitly.

Syntax

BOOL TreeView_DeleteItem(
   HWND      hwnd,
   HTREEITEM hitem
);

Parameters

hwnd

Type: HWND

Handle to the tree-view control.

hitem

Type: HTREEITEM

HTREEITEM handle to the item to delete. If hitem is set to TVI_ROOT, all items are deleted from the tree-view control. You can also use the TreeView_DeleteAllItems macro to delete all items.

Return value

Type: BOOL

Returns TRUE if successful, or FALSE otherwise.

Remarks

It is not safe to delete items in response to a notification such as TVN_SELCHANGING.

Once an item is deleted, its handle is invalid and cannot be used.

The parent window receives a TVN_DELETEITEM notification code when each item is removed.

If the item label is being edited, the edit operation is canceled and the parent window receives the TVN_ENDLABELEDIT notification code.

If you delete all items in a tree-view control that has the TVS_NOSCROLL style, items subsequently added may not display properly. For more information, see TreeView_DeleteAllItems.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header commctrl.h