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. Using Treeview Control

Using Treeview Control

Scheduled Pinned Locked Moved C#
help
7 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.
  • M Offline
    M Offline
    manowj
    wrote on last edited by
    #1

    Hi Everyone, I need to change the forecolor to Red and backcolor to blue when a node is selected in a treeview. Can anyone help me in this regard.

    Regards, Manowj

    N 1 Reply Last reply
    0
    • M manowj

      Hi Everyone, I need to change the forecolor to Red and backcolor to blue when a node is selected in a treeview. Can anyone help me in this regard.

      Regards, Manowj

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Handle NodeMouseClick event. You will get the node selected by checking TreeNodeMouseClickEventArgs.Node. TreeNode has BackColor and ForeColor properties. Reading the documentation is always a good practice

      Navaneeth How to use google | Ask smart questions

      M 1 Reply Last reply
      0
      • N N a v a n e e t h

        Handle NodeMouseClick event. You will get the node selected by checking TreeNodeMouseClickEventArgs.Node. TreeNode has BackColor and ForeColor properties. Reading the documentation is always a good practice

        Navaneeth How to use google | Ask smart questions

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

        Hi Navaneeth, Thanks for your response. Iam using VS2003 IDE. "NodeMouseClick" is not available. Please let me know how to proceed.

        Regards, Manowj

        N 1 Reply Last reply
        0
        • M manowj

          Hi Navaneeth, Thanks for your response. Iam using VS2003 IDE. "NodeMouseClick" is not available. Please let me know how to proceed.

          Regards, Manowj

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Try AfterSelect.

          Navaneeth How to use google | Ask smart questions

          M 1 Reply Last reply
          0
          • N N a v a n e e t h

            Try AfterSelect.

            Navaneeth How to use google | Ask smart questions

            M Offline
            M Offline
            manowj
            wrote on last edited by
            #5

            I tried with "Treeview_AfterSelect", color change is not happening.

            Regards, Manowj

            N 1 Reply Last reply
            0
            • M manowj

              I tried with "Treeview_AfterSelect", color change is not happening.

              Regards, Manowj

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              Here is a code which worked at my end

              private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e){
              e.Node.BackColor = Color.Blue;
              e.Node.ForeColor = Color.Red;
              }

              Navaneeth How to use google | Ask smart questions

              M 1 Reply Last reply
              0
              • N N a v a n e e t h

                Here is a code which worked at my end

                private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e){
                e.Node.BackColor = Color.Blue;
                e.Node.ForeColor = Color.Red;
                }

                Navaneeth How to use google | Ask smart questions

                M Offline
                M Offline
                manowj
                wrote on last edited by
                #7

                Navaneeth, Eg., I have treeview like this Root -> A1 -> A B C In your case when I select A it gives Root as red in color. A should be colored as RED.(Node which is focussed). Please let me know if i am wrong.

                Regards, Manowj

                modified on Tuesday, November 11, 2008 7:54 AM

                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