Sdílet prostřednictvím


CTreeCtrl::GetChildItem

Call this function to retrieve the tree view item that is the child of the item specified by hItem.

HTREEITEM GetChildItem(
   HTREEITEM hItem 
) const;

Parameters

  • hItem
    Handle of a tree item.

Return Value

The handle of the child item if successful; otherwise NULL.

Example

HTREEITEM hmyItem = m_TreeCtrl.GetSelectedItem();

// Delete all of the children of hmyItem.
if (m_TreeCtrl.ItemHasChildren(hmyItem))
{
   HTREEITEM hNextItem;
   HTREEITEM hChildItem = m_TreeCtrl.GetChildItem(hmyItem);

   while (hChildItem != NULL)
   {
      hNextItem = m_TreeCtrl.GetNextItem(hChildItem, TVGN_NEXT);
      m_TreeCtrl.DeleteItem(hChildItem);
      hChildItem = hNextItem;
   }
}

Requirements

Header: afxcmn.h

See Also

Reference

CTreeCtrl Class

Hierarchy Chart

CTreeCtrl::GetItem

CTreeCtrl::GetParentItem

CTreeCtrl::SortChildren

Other Resources

CTreeCtrl Members