You are on page 1of 1

Dim node As TreeNode = DirectCast(sender,

TreeView).SelectedNode
>
If node.Parent Is Nothing Then
MsgBox(String.Format("You clicked a parent node named
{0}", node.Text))
Else
Dim parent As TreeNode = node.Parent
While Not parent.Parent Is Nothing
parent = parent.Parent
End While
MsgBox(String.Format("The node's parent is {0}",
parent.Text))

You might also like