MFC Tree Control: How to expand/collapse a branch?
Q: How to expand/collapse a branch?
A: If you want to expand or collapse one only item use
Code:
m_tree.Expand(hItem, TVE_EXPAND); // or 'TVE_COLLAPSE'
If you want to expand or collapse an item and all of its children use something like this:
Code:
void ExpandTreeItem(const CTreeCtrl &tree, HTREEITEM hItem, UINT nCode) { HTREEITEM hChild; if(tree.ItemHasChildren(hItem)) { tree.Expand(hItem, nCode); hChild = tree.GetChildItem(hItem); while(hChild) { ExpandTreeItem(tree, hChild, nCode); hChild = tree.GetNextItem(hChild, TVGN_NEXT); } } }
Last edited by Andreas Masur; July 25th, 2005 at 04:57 PM.
출처 – http://forums.codeguru.com/showthread.php?231228-MFC-Tree-Control-How-to-expand-collapse-a-branch
댓글 남기기