TreeView - Loop through all nodes and child nodes

Hi. I am trying to loop through all nodes  and child nodes in a TreeView.
The following code just loop through the first two levels of nodes.
I don't know how many levels there are so I need to find code that
automatically finds all nodes and TreeNodes

   For i As Integer = 0 To Me.TreeViewOrg.Nodes.Count - 1
            oNodeText = Me.TreeViewOrg.Nodes(i).Text


  For i As Integer = 0 To Me.TreeViewOrg.Nodes(0).ChildNodes.Count - 1
            oNodeText = Me.TreeViewOrg.Nodes(0).ChildNodes(i).Text
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
Try with a recursive function. Example code in link
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Perfect. Did the trick! Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.