ASP.net VB.net 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

        Next

  For i As Integer = 0 To Me.TreeViewOrg.Nodes(0).ChildNodes.Count - 1
            oNodeText = Me.TreeViewOrg.Nodes(0).ChildNodes(i).Text
   
        Next
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
CodeCruiserCommented:
Try with a recursive function. Example code in link

http://www.freevbcode.com/ShowCode.asp?ID=2203
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Perfect. Did the trick! Thanks
0
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.