Hi all,
My codes:
private void btnRemove_Click(object sender, EventArgs e)
{
RemoveCheckedNodes(treeView1.Nodes);
}
private void RemoveCheckedNodes(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes){
if (node.Checked){nodes.Remove(node);}
else{RemoveCheckedNodes(node.Nodes);}
}
}
Thanks.

VulpesPosted Dec 11, 2014, 6:59 AM
I'm iterating backwards through the nodes collection so that removing a node doesn't change the indices of the nodes still to be examined:
Ken HPosted Dec 11, 2014, 8:15 PM