Solved TreeView - Loop through all nodes and child nodes

Posted on 2012-08-28
Last Modified: 2012-08-29
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
Question by:murbro
    LVL 83

    Accepted Solution

    Try with a recursive function. Example code in link

    Author Closing Comment

    Perfect. Did the trick! Thanks

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now