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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to set focus to newly added CTreeCtrl tree item?

How to set focus to newly added CTreeCtrl tree item?

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structurestutorialquestion
5 Posts 3 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.
  • Y Offline
    Y Offline
    yogish293
    wrote on last edited by
    #1

    Hi i have created CTreeCtrl tree view,this is having list of children (parent child relationship) like normal windows explorer tree view.if i add any new item into the any of root node it will add as a last item of that root node.my problem is once i add new item to the root node,how to set focus to the added item also how to make it visible. 1.parent is already expanded, add new item to the parent. 2.parent is in collapsed state, add new item to the parent. In 1st case i am not able to make visible to the newly added item... please help me... thanks

    L T 2 Replies Last reply
    0
    • Y yogish293

      Hi i have created CTreeCtrl tree view,this is having list of children (parent child relationship) like normal windows explorer tree view.if i add any new item into the any of root node it will add as a last item of that root node.my problem is once i add new item to the root node,how to set focus to the added item also how to make it visible. 1.parent is already expanded, add new item to the parent. 2.parent is in collapsed state, add new item to the parent. In 1st case i am not able to make visible to the newly added item... please help me... thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm not sure offhand but I would expect that forcing a refresh of the CTreeView would get the item displayed.

      The best things in life are not things.

      Y 1 Reply Last reply
      0
      • L Lost User

        I'm not sure offhand but I would expect that forcing a refresh of the CTreeView would get the item displayed.

        The best things in life are not things.

        Y Offline
        Y Offline
        yogish293
        wrote on last edited by
        #3

        Let me try...

        1 Reply Last reply
        0
        • Y yogish293

          Hi i have created CTreeCtrl tree view,this is having list of children (parent child relationship) like normal windows explorer tree view.if i add any new item into the any of root node it will add as a last item of that root node.my problem is once i add new item to the root node,how to set focus to the added item also how to make it visible. 1.parent is already expanded, add new item to the parent. 2.parent is in collapsed state, add new item to the parent. In 1st case i am not able to make visible to the newly added item... please help me... thanks

          T Offline
          T Offline
          Tony Hill
          wrote on last edited by
          #4

          Why not use CTreeCtrl::EnsureVisible

          Y 1 Reply Last reply
          0
          • T Tony Hill

            Why not use CTreeCtrl::EnsureVisible

            Y Offline
            Y Offline
            yogish293
            wrote on last edited by
            #5

            yes.. EnsureVisible is working if parent node is in Collapsed state.that time if make if (hParent != NULL) m_TreeCtrl.Expand(hParent, TVE_EXPAND); // Ensure the item is visible. m_TreeCtrl.EnsureVisible(hmyItem); like this its working,in my case parent is already expanded, i want to make perticular item visible once i add.

            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