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#
  4. TreeNode.FullPath

TreeNode.FullPath

Scheduled Pinned Locked Moved C#
question
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.
  • Z Offline
    Z Offline
    zaboboa
    wrote on last edited by
    #1

    Hello, If I have a full path to the selected node, is there a way to expand the treeview after I refresh it, to that particular node using the path? Thank you!

    S Mircea PuiuM 2 Replies Last reply
    0
    • Z zaboboa

      Hello, If I have a full path to the selected node, is there a way to expand the treeview after I refresh it, to that particular node using the path? Thank you!

      S Offline
      S Offline
      Seishin
      wrote on last edited by
      #2

      string nodeToFind = "node11"; // node's you want to show name TreeNode[] nodes = treeView1.Nodes.Find(nodeToFind, true); if(nodes != null && nodes.Length > 0){ TreeNode node = nodes[0]; while(node != treeView1.TopNode){ node.Parent.Expand(); node = node.Parent; } }

      life is study!!!

      Z 1 Reply Last reply
      0
      • S Seishin

        string nodeToFind = "node11"; // node's you want to show name TreeNode[] nodes = treeView1.Nodes.Find(nodeToFind, true); if(nodes != null && nodes.Length > 0){ TreeNode node = nodes[0]; while(node != treeView1.TopNode){ node.Parent.Expand(); node = node.Parent; } }

        life is study!!!

        Z Offline
        Z Offline
        zaboboa
        wrote on last edited by
        #3

        Thank you very much. The only problem, if you don't set the name of the node, you are out of luck. :-(

        1 Reply Last reply
        0
        • Z zaboboa

          Hello, If I have a full path to the selected node, is there a way to expand the treeview after I refresh it, to that particular node using the path? Thank you!

          Mircea PuiuM Offline
          Mircea PuiuM Offline
          Mircea Puiu
          wrote on last edited by
          #4

          Whenever you add a node, get its full path and store it into node's name. TreeNode tn = this.treeView1.Nodes.Add("AAA"); tn.Name = tn.FullPath; When you want to expand the node having, let's say, "The_wanted_path" you use this:

          TreeNode [] tn = this.treeView1.Nodes.Find("The_wanted_path", true);
          if ( tn[0] != null )
          {
          TreeNode Parent = tn[0].Parent;
          TreeNode FirstParent = Parent;
          while (Parent != null)
          {
          Parent = Parent.Parent;
          if (Parent != null) FirstParent = Parent;
          }
          tn[0].Expand();
          if (FirstParent != null) FirstParent.Expand();
          }

          SkyWalker

          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