Ctreectrl problem
-
Hello All, Iam using CTreeCtrl method to add items in a tree.Actually i create two root nodes using GetRootNode()method.I add both root nodes properly in the tree,But what's my problem is i need to add child nodes in appropriate parent(root)nodes at runtime.But,all the child nodes adding in the first parent(root)node only.once i use deleteallitems()method and redraw the tree only child nodes are added in appropriate parent(root)nodes.Without using DeleteAllItems() i need to add the child nodes in a appropriate parent(root)node. please anybody help me. Thanks in advance, Regards, bhanu.
-
Hello All, Iam using CTreeCtrl method to add items in a tree.Actually i create two root nodes using GetRootNode()method.I add both root nodes properly in the tree,But what's my problem is i need to add child nodes in appropriate parent(root)nodes at runtime.But,all the child nodes adding in the first parent(root)node only.once i use deleteallitems()method and redraw the tree only child nodes are added in appropriate parent(root)nodes.Without using DeleteAllItems() i need to add the child nodes in a appropriate parent(root)node. please anybody help me. Thanks in advance, Regards, bhanu.
I'm not really sure what your problem is... Try this:
CTreeCtrl *pTree = (CTreeCtrl *)GetDlgItem (IDC_MYTREE);
// Add two root items
HTREEITEM hRootOne = pTree->InsertItem ("Root One", TVI_ROOT);
HTREEITEM hRootTwo = pTree->InsertItem ("Root Two", TVI_ROOT);// Add one child to first root item
pTree->InsertItem ("Child One", hRootOne);// Add two children to second root item
pTree->InsertItem ("Child Alpha", hRootTwo);
pTree->InsertItem ("Child Beta", hRootTwo);Note the use of TVI_ROOT for the root items, and that I keep track of the return values to use later. Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...