Question Select SubNode in TreeView

Knvn

Well-known member
Joined
Dec 30, 2009
Messages
45
Programming Experience
Beginner
How to select a Sub node in treeview?

In wrote following code to store the Selected node for further use.

VB.NET:
Dim SelectedNode As TreeNode= TreeView.SelectedNode

I wrote this code to select the desigred node but it shoudn’t work.

VB.NET:
TreeView.SelectedNode = SelectedNode
TreeView.Select()
TreeView.SelectedNode.Expand()

While tracing ‘SelectedNode.Fullpath’ shows “RootNode\SubNode” but in ‘TreeView.SelectedNode.Fullpath’ it shows only “RootNode”. And so only the root node will get selects and expands.

I want to know why this happends and how to select the subnode exactly.
 
The last code will work if you have correct reference, it sounds as you somewhere along the way has replaced that with a reference to the root node.
 
Back
Top