Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView scroll to first node

Status
Not open for further replies.

forecasting

Programmer
May 2, 2002
130
I am building a treeview from a list that requires building the children before the parents. I seem to have the reconstruction of the Tree down pretty well, but when I open the list I am not at the first node. What's more, the first node isn't even shown on the screen.

Since I seem to have gone brain dead, does anyone know a quick way to navigate and select the first node, when your current selected node is somewhere in the middle?
 

If TreeView.Nodes.Count > 0 Then
TreeView.Nodes(1).Selected = True
End If
 
Since he did not start adding nodes with the root node when he added them, #1 in the collection isn't necessarily going to be that node.

He should be able to check the currently selected node, and if it has a parent then set the selected node to that, then keep looping through this until the selected node does not have a parent.

Robert
 
Thanks

I also found that I had to select the root to get to the top node once I got to the top level node without a parent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top