back-forward

Does anybody know how to add back and forward buttons on a treeview to view txt files
xnightAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Martin LissConnect With a Mentor Older 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
 
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
All Courses

From novice to tech pro — start learning today.