VB.NET TreeView move to next node

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adh

    VB.NET TreeView move to next node

    How do you move by program to the next node of a treeview (NextButton)?
    Thanks


  • Peter Huang [MSFT]

    #2
    RE: VB.NET TreeView move to next node

    Hi

    1. We can use the SelectedNode to get the current selected node
    2. We use the NextNode Property to retrieve the next node
    3. We set the NextNode to the SelectedNode, so that the "NextNode" will be
    the current selected node.
    e.,g.
    Me.TreeView1.Se lectedNode = Me.TreeView1.Se lectedNode.Next Node


    Best regards,

    Peter Huang
    Microsoft Online Partner Support

    Get Secure! - www.microsoft.com/security
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    • adh

      #3
      RE: VB.NET TreeView move to next node

      Thanks for the prompt reply.
      My Nodes are sub nodes of Node(0) so
      .Nodes(0).NextN ode
      Did not work for me (it jumps to Node(1) not to the next sub node)
      2)
      .NextNode does not check the end of nodes. so what I'm using is:
      With stvView.trvView s
      If .Nodes(0).LastN ode.Index = .SelectedNode.I ndex Then
      .SelectedNode = .Nodes(0).Nodes (0)
      Else
      .SelectedNode = .Nodes(0).Nodes (.SelectedNode. Index + 1)
      End If
      End With

      ????

      Thanks, adh

      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Robin Tucker

        #4
        Re: VB.NET TreeView move to next node

        Sure that will work, but you will screw up when you get to the end of a
        branch and want to come back down the other side (if you see what I mean).

        A proper traversal of a tree, in order, requires a stack (or recursion).
        Your code below will traverse from the current position to the nearest leaf.

        "adh" <adh@devx.com > wrote in message
        news:e44EnLJqFH A.2724@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Thanks for the prompt reply.
        > My Nodes are sub nodes of Node(0) so
        > Nodes(0).NextNo de
        > Did not work for me (it jumps to Node(1) not to the next sub node)
        > 2)
        > NextNode does not check the end of nodes. so what I'm using is:
        > With stvView.trvView s
        > If .Nodes(0).LastN ode.Index = .SelectedNode.I ndex Then
        > .SelectedNode = .Nodes(0).Nodes (0)
        > Else
        > .SelectedNode = .Nodes(0).Nodes (.SelectedNode. Index + 1)
        > End If
        > End With
        >
        > ????
        >
        > Thanks, adh
        >
        > *** Sent via Developersdex http://www.developersdex.com ***[/color]


        Comment

        • adh

          #5
          Re: VB.NET TreeView move to next node

          OK. Got it.
          Thanks, adh

          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Peter Huang [MSFT]

            #6
            Re: VB.NET TreeView move to next node

            Hi

            I agree with Robin's suggestion.
            If you wants to traverse a tree strcture of treenodes, you need to use
            recursion or stack.

            Best regards,

            Peter Huang
            Microsoft Online Partner Support

            Get Secure! - www.microsoft.com/security
            This posting is provided "AS IS" with no warranties, and confers no rights.

            Comment

            Working...