I have this code to select first node of TreeView. But when page loads the by default root node is other than first, I want to set the selected node as top most by default. Here is my code in page load but it’s not working:
Dim nodes As TreeNodeCollection = TreeView1.Nodes
If nodes.Count > 0 Then
' Select the root node
TreeView1.SelectedNode = nodes(0)
End If
This gives the blue underline error on this line:
TreeView1.SelectedNode = nodes(0)
The error is:
“Selected Node Property is read Only”
Please any one tell me how can I do this?
To select a node you need to set the selected property on the node itself:
Equally you can use: