CTreeCtrl::Select

Call this function to select the given tree view item, scroll the item into view, or redraw the item in the style used to indicate the target of a drag-and-drop operation.

BOOL Select(
   HTREEITEM hItem,
   UINT nCode 
);

Parameters

  • hItem
    Handle of a tree item.

  • nCode
    The type of action to take. This parameter can be one of the following values:

    • TVGN_CARET   Sets the selection to the given item.

    • TVGN_DROPHILITE   Redraws the given item in the style used to indicate the target of a drag-and-drop operation.

    • TVGN_FIRSTVISIBLE   Scrolls the tree view vertically so that the given item is the first visible item.

Return Value

Nonzero if successful; otherwise 0.

Remarks

If nCode contains the value TVGN_CARET, the parent window receives the TVN_SELCHANGING and TVN_SELCHANGED notification messages. In addition, if the specified item is the child of a collapsed parent item, the parent's list of child items is expanded to reveal the specified item. In this case, the parent window receives the TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages.

Example

See the example for CTreeCtrl::HitTest.

Requirements

Header: afxcmn.h

See Also

Reference

CTreeCtrl Class

Hierarchy Chart

CTreeCtrl::SelectItem

CTreeCtrl::GetSelectedItem

CTreeCtrl::SelectDropTarget

Other Resources

CTreeCtrl Members