K
Kevin993
Guest
Greetings,
By default, if a parent node is checked, its child nodes don't get checked. so :
Private Sub CheckAllChildNodes(ByVal treeNode As TreeNode, ByVal nodeChecked As Boolean)
For Each node As TreeNode In treeNode.Nodes
node.Checked = nodeChecked
If node.Nodes.Count > 0 Then
Me.CheckAllChildNodes(node, nodeChecked)
End If
Next
End Sub
The code above works fine (handling NodeCheckedChanged with setting nodeChecked to true (checking the parent node and all its child nodes) or false (checking the parent node and all its child nodes). However If a child node gets checked, its parent node doesn't. and even if the parent is checked when checking a child node, the code above checks all the child nodes. This is the first issue. Any suggestion ?
After solving the above issue: User checks desired parent nodes (or if a single child node is checked, the parent should be checked, but checking the parent node shouldn't check all the child nodes), then with clicking a button all the unchecked parent or child nodes should be removed. I found this to iterate through all nodes of treeview. That's fine. but removing a node while iterating changes the collection of the loop and ... .
I appreciate any help.
Continue reading...
By default, if a parent node is checked, its child nodes don't get checked. so :
Private Sub CheckAllChildNodes(ByVal treeNode As TreeNode, ByVal nodeChecked As Boolean)
For Each node As TreeNode In treeNode.Nodes
node.Checked = nodeChecked
If node.Nodes.Count > 0 Then
Me.CheckAllChildNodes(node, nodeChecked)
End If
Next
End Sub
The code above works fine (handling NodeCheckedChanged with setting nodeChecked to true (checking the parent node and all its child nodes) or false (checking the parent node and all its child nodes). However If a child node gets checked, its parent node doesn't. and even if the parent is checked when checking a child node, the code above checks all the child nodes. This is the first issue. Any suggestion ?
After solving the above issue: User checks desired parent nodes (or if a single child node is checked, the parent should be checked, but checking the parent node shouldn't check all the child nodes), then with clicking a button all the unchecked parent or child nodes should be removed. I found this to iterate through all nodes of treeview. That's fine. but removing a node while iterating changes the collection of the loop and ... .
I appreciate any help.
Continue reading...