Im struggling with what I think should be a basic recursion of my Treeview but I cant seem to get the logic correct.
Essentially I have a WinForms Treeview (C# Net Framework 4.5.1) which has a list of nodes which are standard Nodes (no custom controls) which have checkboxes enabled for each node.
It is a dynamic Treeview so the nodes are not a fixed length deep, but can essentially has any number of SubNodes which can also have more Subnodes (hope that makes sense).
What I am trying to achieve is returning the Top Level Checked Nodes if all there Child Nodes are all checked or if not all child nodes are checked, return the list of Checked Nodes.
Some Examples are below :-
- Node 1 (X)
- Node 2 (X)
- Node 3 (X)
- Node 4 (X)
- Node 5 (X)
- Node 2 (X)
This example would return Node 1 as all its Sub Nodes (and subsequent subnodes) are checked
- Node 1 (X)
- Node 2 (X)
- Node 3 (X)
- Node 4
- Node 5 (X)
- Node 2 (X)
This would return Node 1 / Node 2 / Node 3 / Node 5
- Node 1 (X)
- Node 2 (X)
- Node 3
- Node 4
- Node 5 (X)
- Node 6 (X)
- Node 7 (X)
- Node 2 (X)
This would return Node 1 / Node 2 / Node 5
- Node 1 (X)
- Node 2 (X)
- Node 3
- Node 4 (X)
- Node 5 (X)
- Node 6
- Node 7 (X)
- Node 2 (X)
This would return Node 1 / Node 2 / Node 4 / Node 5 / Node 7
Any help would be appreciated.
Thanks.
Hi Deacon Kelly, you can use this method.