[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2382
  • Last Modified:

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


  For i As Integer = 0 To Me.TreeViewOrg.Nodes(0).ChildNodes.Count - 1
            oNodeText = Me.TreeViewOrg.Nodes(0).ChildNodes(i).Text
Murray Brown
Murray Brown
1 Solution
Try with a recursive function. Example code in link

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Perfect. Did the trick! Thanks

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now