finding same indexed node in two treeviews

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Raventara
    New Member
    • Aug 2007
    • 11

    #1

    finding same indexed node in two treeviews

    Hi-a all,
    I have two treeviews on a form (VB.NET) and one of them contains words, and the other commands. Each word has a command assigned to it. I chose to show this in a treeview as certain words have secondary words (like, "move" and "up"). I would love it if someone could explain to me how I could select the matching command from the hidden command treeview when someone selects a word in the other treeview.

    Please help - these treeviews are driving me crazazy!

    Thanks,

    Rustle
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Write this code in AfterSelect Event of the Main Tree.:

    [code=vb]
    Me.TreeView2.Se lectedNode = Me.TreeView1.Se lectedNode
    [/code]

    Regards
    Veena

    Comment

    • Raventara
      New Member
      • Aug 2007
      • 11

      #3
      Originally posted by QVeen72
      Hi,

      Write this code in AfterSelect Event of the Main Tree.:

      [code=vb]
      Me.TreeView2.Se lectedNode = Me.TreeView1.Se lectedNode
      [/code]

      Regards
      Veena
      Hi, I did try that (first thing) but it did not seem to work... I will try it again...

      Thanks

      Comment

      • Raventara
        New Member
        • Aug 2007
        • 11

        #4
        OK, that method just did nothing at all. Don't know why. I have ended up doing the following:

        Code:
               Dim treenode As New TreeNode
        
                TreeNode = TREE_COMMANDS.Nodes(e.Node.Name)
                If TreeNode Is Nothing Then
                    TreeNode = TREE_COMMANDS.Nodes("root").Nodes(e.Node.Name)
                    If TreeNode Is Nothing Then
                        TreeNode = TREE_COMMANDS.Nodes("root").Nodes(e.Node.Parent.Name).Nodes(e.Node.Name)
                    End If
                End If
        This of course only works for three levels, but I will not have any more than 3 levels so this is fine.

        If anyone has any comments/improvements I'm well open to them

        Cheers,

        Rustle

        Comment

        Working...