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. Treeview control - selecting a particular child node by coding

Treeview control - selecting a particular child node by coding

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
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.
  • C Offline
    C Offline
    chandler83
    wrote on last edited by
    #1

    Hi i have a tree view control in my application. and they all have one level of child nodes. How can i select a particular child node by coding. eg, a 1 2 b 11 12 13 in this above how can i highlight the 12 node.i.e making the 12 node to look as if it is selected. plzz help. thanks in advance.........:confused:

    M K 2 Replies Last reply
    0
    • C chandler83

      Hi i have a tree view control in my application. and they all have one level of child nodes. How can i select a particular child node by coding. eg, a 1 2 b 11 12 13 in this above how can i highlight the 12 node.i.e making the 12 node to look as if it is selected. plzz help. thanks in advance.........:confused:

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! First you have to get a reference to the node you want to select and then you just have to call myTreeView.SelectedNode = theNodeReference;

      Regards, mav -- Black holes are the places where god divided by 0...

      C 1 Reply Last reply
      0
      • M mav northwind

        Hi! First you have to get a reference to the node you want to select and then you just have to call myTreeView.SelectedNode = theNodeReference;

        Regards, mav -- Black holes are the places where god divided by 0...

        C Offline
        C Offline
        chandler83
        wrote on last edited by
        #3

        thanks for ur reply but then if u pass the node reference of a child node it is not accepting.... can u help me more plzzzzz

        M 1 Reply Last reply
        0
        • C chandler83

          thanks for ur reply but then if u pass the node reference of a child node it is not accepting.... can u help me more plzzzzz

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          What do you mean by "it is not accepting"? Either you have a reference to an existing node anywhere inside your tree, in which case the mechanism is working, or you don't have a reference to an existing node, in which case I'd expect the treeview to not select anything. But without any code from your side it's impossible to tell what you did wrong.

          Regards, mav -- Black holes are the places where god divided by 0...

          1 Reply Last reply
          0
          • C chandler83

            Hi i have a tree view control in my application. and they all have one level of child nodes. How can i select a particular child node by coding. eg, a 1 2 b 11 12 13 in this above how can i highlight the 12 node.i.e making the 12 node to look as if it is selected. plzz help. thanks in advance.........:confused:

            K Offline
            K Offline
            kozu
            wrote on last edited by
            #5

            Try something like this: foreach (TreeNode node in myTree.Nodes) { if (node.Text == "12") { myTree.SelectedNode=node; break; } }

            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