back-forward

Does anybody know how to add back and forward buttons on a treeview to view txt files
xnightAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Add Backward and Forward (or Up and Down like I've done) to a toolbar, and attach the following code:
Public Function Up(ndNode As TreeView) As String

    On Error GoTo ErrorRoutine
   
    If ndNode.SelectedItem.Index = 1 Then
        IsFirstNode = True
        Up = ""
        Exit Function
    Else
        IsFirstNode = False
    End If
   
    If ndNode.SelectedItem.Index > 1 Then
        ndNode.Nodes(ndNode.SelectedItem.Index).Expanded = True
        ndNode.SelectedItem = ndNode.Nodes(ndNode.SelectedItem.Index - 1)
    End If
   
    Up = ndNode.Nodes.Item(ndNode.SelectedItem.Index).Key
   
    Exit Function
   
ErrorRoutine:

    ClassError "Up"

End Function

Public Function Down(ndNode As TreeView) As String

    On Error GoTo ErrorRoutine
   
    If ndNode.SelectedItem.Index = ndNode.Nodes.Count Then
        IsLastNode = True
        Down = ""
        Exit Function
    Else
        IsLastNode = False
    End If

    If ndNode.SelectedItem.Index < ndNode.Nodes.Count Then
        ndNode.Nodes(ndNode.SelectedItem.Index).Expanded = True
        ndNode.SelectedItem = ndNode.Nodes(ndNode.SelectedItem.Index + 1)
    End If
   
    Down = ndNode.Nodes.Item(ndNode.SelectedItem.Index).Key
   
    Exit Function
   
ErrorRoutine:

    ClassError "Down"

End Function

The IsFirstNode and IsLastNode variables allow you to add code to "wrap" to the first or last node if you are already at the last or first.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jgvCommented:
This will move among nodes on the same level. It is written assuming that you are placing the file name in the tag property of each node. I used two command buttons in an array (cmdMove).

Private Sub cmdMove_Click(Index As Integer)

Dim filename As String

If TreeView1.SelectedItem Is Nothing Then Exit Sub

Select Case Index
   
    Case 0 'move up
        If TreeView1.SelectedItem = TreeView1.SelectedItem.FirstSibling Then Exit Sub
        TreeView1.SelectedItem = TreeView1.SelectedItem.Previous
   
    Case 1 'move down
        If TreeView1.SelectedItem = TreeView1.SelectedItem.LastSibling Then Exit Sub
        TreeView1.SelectedItem = TreeView1.SelectedItem.Next

End Select

filename = TreeView1.SelectedItem.Tag

End Sub

0
xnightAuthor Commented:
i'll see how it works......thanks!!!!
0
xnightAuthor Commented:
i forgot to mention that i am using an ini file.....does it make a difference?
0
xnightAuthor Commented:
Well they dont work.....maybe because i am usin an ini file?......answers are still good
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.