Sdílet prostřednictvím


CTreeCtrl::GetSelectedItem

Call this function to retrieve the currently selected item of the tree view control.

HTREEITEM GetSelectedItem( ) const;

Return Value

The handle of the selected item; otherwise NULL.

Example

// Expand the selected item and make it visible, if possible.
HTREEITEM hItem = m_TreeCtrl.GetSelectedItem();

if ((hItem != NULL) && m_TreeCtrl.ItemHasChildren(hItem))
{
   m_TreeCtrl.Expand(hItem, TVE_EXPAND);
   m_TreeCtrl.EnsureVisible(hItem);
}

Requirements

Header: afxcmn.h

See Also

Reference

CTreeCtrl Class

Hierarchy Chart

CTreeCtrl::Select

CTreeCtrl::SelectDropTarget

CTreeCtrl::GetDropHilightItem

Other Resources

CTreeCtrl Members