popel
New member
How can I Collect all the Checked Child Nodes Name From a TreeView Control Using VB.NET Windows Applications. Thanks In Advanced.
Popel
Popel
Yes..... u r right. There are more than 20 root nodes and every root nodes have more than 30 child node. Again few child nodes have one or two child. Specially i want to collect all the node name which are checked. Thanks For ur Reply. SORRY FOR MY POOR ENGLISH.When you say "child nodes" do you mean specifically not root nodes, i.e. not the nodes at he top level but all others? If so, how deep does your tree go? Is there just one level of children below the root nodes or can there be more?
Private Function GetCheckedChildNodes(ByVal nodes As TreeNodeCollection) As TreeNode()
Dim checkedNodes As New List(Of TreeNode)
For Each node As TreeNode In nodes
If node.Checked AndAlso node.Level > 0 Then
checkedNodes.Add(node)
End If
checkedNodes.AddRange(Me.GetCheckedChildNodes(node.Nodes))
Next
Return checkedNodes.ToArray()
End Function
Private Sub Button1_Click() Handles Button1.Click
For Each node In Me.GetCheckedChildNodes(Me.TreeView1.Nodes)
Console.WriteLine(node.FullPath)
Next
End Sub