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#
  4. TreeView Node selection

TreeView Node selection

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 1 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.
  • D Offline
    D Offline
    Dylan van Heerden
    wrote on last edited by
    #1

    Hi How can I select a treenode (in coding) on a treeview and keep it selected (High Lighted)? I tried the following and it doesn't seem to work as required: foreach ( TreeNode tn in treeView1.Nodes ) { if ( tn.Text == "Color" ) { treeView1.SelectedNode = tn break; } }

    M 1 Reply Last reply
    0
    • D Dylan van Heerden

      Hi How can I select a treenode (in coding) on a treeview and keep it selected (High Lighted)? I tried the following and it doesn't seem to work as required: foreach ( TreeNode tn in treeView1.Nodes ) { if ( tn.Text == "Color" ) { treeView1.SelectedNode = tn break; } }

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

      Why isn't it "working as expected"? That's how you select a node, no need to perform different or additional voodoo. Could it be that your TreeView hasn't got focus and HideSelection is set to true? Or that there _is_ no node with Text "Color"? mav

      D 1 Reply Last reply
      0
      • M mav northwind

        Why isn't it "working as expected"? That's how you select a node, no need to perform different or additional voodoo. Could it be that your TreeView hasn't got focus and HideSelection is set to true? Or that there _is_ no node with Text "Color"? mav

        D Offline
        D Offline
        Dylan van Heerden
        wrote on last edited by
        #3

        Ok must be that the treeview hasn't got focus... Thanks

        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