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. Select treenode automatically

Select treenode automatically

Scheduled Pinned Locked Moved C#
data-structures
10 Posts 4 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.
  • K Offline
    K Offline
    kmb89
    wrote on last edited by
    #1

    My form has two tree views. If select treenode from first tree with UpArrow or DownArrow button from keyboard, i want the treenode from the second treeview to be selected automatically. These treeviews have the same treenode. Thanks axiom.kid :confused:

    C 1 Reply Last reply
    0
    • K kmb89

      My form has two tree views. If select treenode from first tree with UpArrow or DownArrow button from keyboard, i want the treenode from the second treeview to be selected automatically. These treeviews have the same treenode. Thanks axiom.kid :confused:

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Is there not a selection changed event on the tree control ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      K 1 Reply Last reply
      0
      • C Christian Graus

        Is there not a selection changed event on the tree control ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        K Offline
        K Offline
        kmb89
        wrote on last edited by
        #3

        There is no selection changed event in treeview.:confused:

        C 1 Reply Last reply
        0
        • K kmb89

          There is no selection changed event in treeview.:confused:

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You are right. There are two. BeforeSelect, and AfterSelect. So, use whichever one you prefer, and as the selection changes, select the right node in the other control.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          K 1 Reply Last reply
          0
          • C Christian Graus

            You are right. There are two. BeforeSelect, and AfterSelect. So, use whichever one you prefer, and as the selection changes, select the right node in the other control.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

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

            No,it doesn't work.

            C 2 Replies Last reply
            0
            • K kmb89

              No,it doesn't work.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Well, if the control is broken, if the events that should fire, do not, then your only other option as far as I can see, is to use a timer to check when one is changed, and then change the other, or use the keyboard events to detect when a keypress occurs on the control, and then from there, check if the selection has changed.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              1 Reply Last reply
              0
              • K kmb89

                No,it doesn't work.

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                Your code sucks. I just wrote a sample project and it works just fine. Press a key to change selection and the beforeselect and afterselect events fire, with a keyup event in the middle. If you want help here, it helps to post your code, so we can tell you where it is broken, although in this case, it's very simple. Hook up the event, and it will fire.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                K M P 3 Replies Last reply
                0
                • C Christian Graus

                  Your code sucks. I just wrote a sample project and it works just fine. Press a key to change selection and the beforeselect and afterselect events fire, with a keyup event in the middle. If you want help here, it helps to post your code, so we can tell you where it is broken, although in this case, it's very simple. Hook up the event, and it will fire.

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  K Offline
                  K Offline
                  kmb89
                  wrote on last edited by
                  #8

                  Thanks a lot for replying me. My two trees worked with the following code. private void sourcetree_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { if(destinationtree.SelectedNode.PrevVisibleNode != null) destinationtree.SelectedNode = destinationtree.SelectedNode.PrevVisibleNode; } else { if(destinationtree.SelectedNode.NextVisibleNode != null) destinationtree.SelectedNode = destinationtree.SelectedNode.NextVisibleNode; } }

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    Your code sucks. I just wrote a sample project and it works just fine. Press a key to change selection and the beforeselect and afterselect events fire, with a keyup event in the middle. If you want help here, it helps to post your code, so we can tell you where it is broken, although in this case, it's very simple. Hook up the event, and it will fire.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    M Offline
                    M Offline
                    Malcolm Smart
                    wrote on last edited by
                    #9

                    Christian Graus wrote:

                    Your code sucks

                    I've not been around for about 8 months - first post I read shows not much as changed around here!! Superb. :)

                    Knowledge is hereditary, it will find its way up or down. Luc Pattyn
                    and since what every time when i want to add button to this control one add two times posted in C# forum

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      Your code sucks. I just wrote a sample project and it works just fine. Press a key to change selection and the beforeselect and afterselect events fire, with a keyup event in the middle. If you want help here, it helps to post your code, so we can tell you where it is broken, although in this case, it's very simple. Hook up the event, and it will fire.

                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #10

                      Christian Graus wrote:

                      Your code sucks.

                      Hey, you're back. :-D

                      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