Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Ctreectrl problem

Ctreectrl problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bhanu_reddy09
    wrote on last edited by
    #1

    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 1 Reply Last reply
    0
    • B bhanu_reddy09

      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 Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups