
Originally Posted by
athenso
Ik but all that does is prints the words of the node selected. I have a text file named BearRoomQuest.txt I want it so when bear room node is selected that the BearRoomQuest.txt is loaded into the text box
To do that, you have to save the path to the file with the node while you populate the tree, use Node's Tag property to save the file path, e.g.
Code:
Private Sub Form2_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim tvNode As TreeNode
tvNode = TreeView1.Nodes.Add("Rook")
tvNode.Tag = "path to Rook.txt"
tvNode = TreeView1.Nodes.Add("Bear Room")
tvNode.Tag = "path to Bear Room.txt"
' add the rest.
End Sub
Then in AfterSelect event
Code:
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
RichTextBox1.LoadFile(e.Node.Tag)
End Sub