Reputation: 121
My treeview looks like this:
Thanks
Upvotes: 0
Views: 2149
Reputation: 121
Got what I was looking for thanks to @dotNET
Private Sub TreeView1_Click(sender As Object, e As EventArgs) Handles TreeView1.AfterSelect
If TreeView1.SelectedNode IsNot Nothing AndAlso TreeView1.SelectedNode.Nodes.Count > 2 Then
Link = TreeView1.SelectedNode.Nodes(2).Text
End If
End Sub
Thanks
Upvotes: 0
Reputation: 35470
It is as simple as using the indexer property of the Nodes
collection of your node, like this:
YourNode.Nodes(2).Text
If you have handled NodeMouseClick
event of your TreeView, the second parameter e as TreeNodeMouseClickEventArgs
can be used like this:
Public Sub YourTreeView_AfterSelect(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs)
If YourTreeView.SelectedNode.Nodes.Count > 2 Then
MsgBox(YourTreeView.SelectedNode.Nodes(2).Text)
Else
MsgBox("No 3rd node is available.")
End Sub
Upvotes: 2