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. Getting the selected tree node's text?

Getting the selected tree node's text?

Scheduled Pinned Locked Moved C#
questioncsharpdata-structures
4 Posts 2 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.
  • M Offline
    M Offline
    Manster
    wrote on last edited by
    #1

    Hi, I've got a question regarding the treeview control on a C# windows form. How can I get the text of the selected treeview node? I know I need the .Text property to get the string, I just can't seem to get the selected/active treenode. I want to take part of that text and put it in a tool tip. I've got the tooltip part working but I'm getting the parent tree nodes text. The tree structure looks like this. Last Name     Smith     Wallace First Name     John     William Thanks :)

    M 1 Reply Last reply
    0
    • M Manster

      Hi, I've got a question regarding the treeview control on a C# windows form. How can I get the text of the selected treeview node? I know I need the .Text property to get the string, I just can't seem to get the selected/active treenode. I want to take part of that text and put it in a tool tip. I've got the tooltip part working but I'm getting the parent tree nodes text. The tree structure looks like this. Last Name     Smith     Wallace First Name     John     William Thanks :)

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      Manster wrote: How can I get the text of the selected treeview node? In away like this:

      string str="";
      if(treeview.SelectedNode!=null)
      str = treeview.SelectedNode.Text

      Mazy No sig. available now.

      M 1 Reply Last reply
      0
      • M Mazdak

        Manster wrote: How can I get the text of the selected treeview node? In away like this:

        string str="";
        if(treeview.SelectedNode!=null)
        str = treeview.SelectedNode.Text

        Mazy No sig. available now.

        M Offline
        M Offline
        Manster
        wrote on last edited by
        #3

        Mazdak, Thanks for your help. I'm actually trying to get the child node from the code you listed above. So if I'm currently getting "Last Name" returned to me now, I'm trying to get "Wallace" instead. This is the tree structure. Last Name     Wallace A child node is selected and I need it's text. Is this possible? This is the tree structure. Thanks

        M 1 Reply Last reply
        0
        • M Manster

          Mazdak, Thanks for your help. I'm actually trying to get the child node from the code you listed above. So if I'm currently getting "Last Name" returned to me now, I'm trying to get "Wallace" instead. This is the tree structure. Last Name     Wallace A child node is selected and I need it's text. Is this possible? This is the tree structure. Thanks

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          SelectedNode has property named FirstNode which you go through it and get child nodes. It contains child nodes of selected node. Mazy No sig. available now.

          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