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. how to set selected node of treeview through code

how to set selected node of treeview through code

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpdotnetdata-structuresjson
4 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.
  • T Offline
    T Offline
    Trucker
    wrote on last edited by
    #1

    Hello, In my Application I made a treeview that displays the system directory structure - like the tree on the left in windows explorer. I also have an Open button that opens a file (OpenFileDialog). So basically my user can browse for a file through the directory tree (the treeview) or through the Open button. My problem is this - If the user chooses to use the Open button to open a file, when she/he does so, I want the treeview to reflect the location of the opened file. That is, to expand appropriately from the root and select the folder that contains the open file. So far I have tried several approaches but none led to a solution:doh:... 1) I looked in the .NET Framework, in TreeView class, for a function that takes a full path and is able to expand to and select the resulting directory. I could not find such a function. 2) I was successfull in parsing the full path I got from the open file dialog window into directories. However I found no functions in the .NET Framework that could help me track from the root to the last directory of the treeview. If anybody knows how to solve this problem or has an approach to solving it, I would appreciate hearing it greatly. TraileR ParK LifE 4Ever

    C J 2 Replies Last reply
    0
    • T Trucker

      Hello, In my Application I made a treeview that displays the system directory structure - like the tree on the left in windows explorer. I also have an Open button that opens a file (OpenFileDialog). So basically my user can browse for a file through the directory tree (the treeview) or through the Open button. My problem is this - If the user chooses to use the Open button to open a file, when she/he does so, I want the treeview to reflect the location of the opened file. That is, to expand appropriately from the root and select the folder that contains the open file. So far I have tried several approaches but none led to a solution:doh:... 1) I looked in the .NET Framework, in TreeView class, for a function that takes a full path and is able to expand to and select the resulting directory. I could not find such a function. 2) I was successfull in parsing the full path I got from the open file dialog window into directories. However I found no functions in the .NET Framework that could help me track from the root to the last directory of the treeview. If anybody knows how to solve this problem or has an approach to solving it, I would appreciate hearing it greatly. TraileR ParK LifE 4Ever

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you looked in the .NET framework, does that make this a Managed C++ ( C++/CLI ) question, or a C# question ? Christian Graus - Microsoft MVP - C++

      T 1 Reply Last reply
      0
      • T Trucker

        Hello, In my Application I made a treeview that displays the system directory structure - like the tree on the left in windows explorer. I also have an Open button that opens a file (OpenFileDialog). So basically my user can browse for a file through the directory tree (the treeview) or through the Open button. My problem is this - If the user chooses to use the Open button to open a file, when she/he does so, I want the treeview to reflect the location of the opened file. That is, to expand appropriately from the root and select the folder that contains the open file. So far I have tried several approaches but none led to a solution:doh:... 1) I looked in the .NET Framework, in TreeView class, for a function that takes a full path and is able to expand to and select the resulting directory. I could not find such a function. 2) I was successfull in parsing the full path I got from the open file dialog window into directories. However I found no functions in the .NET Framework that could help me track from the root to the last directory of the treeview. If anybody knows how to solve this problem or has an approach to solving it, I would appreciate hearing it greatly. TraileR ParK LifE 4Ever

        J Offline
        J Offline
        Jose Lamas Rios
        wrote on last edited by
        #3

        Did you know that the "Quote Selected Text" button doesn't work when replying to your posts? I think it may be related to the > character in your signature. Would you mind removing or at least escaping it? Instead of > you can write > and it will still show the same way. Hopefully, that will fix the problem. -- jlr http://jlamas.blogspot.com/[^]

        1 Reply Last reply
        0
        • C Christian Graus

          If you looked in the .NET framework, does that make this a Managed C++ ( C++/CLI ) question, or a C# question ? Christian Graus - Microsoft MVP - C++

          T Offline
          T Offline
          Trucker
          wrote on last edited by
          #4

          To Christian - this is a Managed C++ question, (Visual C++ .NET) To Jose - Thanks for da tip. I changed my signature but the Quote button still refuses to work. I suspect its because it doesn't like any brackets in the message contents but I decided to not take those out because it would make the message less organized (...or maybe because im just to laizy to reorganize everything;P). In any case, if its not too big of a trouble, can u please just manually refer to the part of my message you want to reply about . Thanks! TraileR ParK LifE 4Ever

          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