How to get a list of all child nodes in a TreeView in .NET

后端 未结 10 1113
抹茶落季
抹茶落季 2020-12-15 21:28

I have a TreeView control in my WinForms .NET application that has multiple levels of childnodes that have childnodes with more childnodes, with no defined depth. When a use

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 21:45

    you need a recursive function to do this [or a loop equivalent, but the recursive version is simpler] - pseudocode:

    function outputNodes(Node root)
        writeln(root.Text)
        foreach(Node n in root.ChildNodes)
            outputNodes(n)
        end
    end
    

提交回复
热议问题