Reputation: 549
I am new to Treeviews and would like to know why the "New Node" is not added to the SelectedNode.
TreeView1.Nodes.Add("Document")
Dim ParentNode As New TreeNode("Document")
TreeView1.SelectedNode = ParentNode
ParentNode.Nodes.Add("New Node")
Upvotes: 1
Views: 66
Reputation: 81620
You created a new Document node that isn't the same node as the Document node that was added to the TreeView nodes collection.
Try it this way:
Dim docNode As New TreeNode("Document")
TreeView1.Nodes.Add(docNode)
TreeView1.SelectedNode = docNode
docNode.Nodes.Add("New Node")
Upvotes: 1