I have a custom tree view inherited from asp.net tree view control. with nth level parent- child relationship. based on some calculation I have checked child node. I want parent node should be checked if all the child node are checked. As I am checking child nodes on based some calculation so I can't use after check event. can some one provide me C# code for that?
private TreeNode _parentNode;
private void CheckedParent(TreeNodeCollection nodeCollection)
{
foreach (TreeNode node in nodeCollection)
{
if (node.ChildNodes.Count > 0)
{
_parentNode = node;
CheckedParent(node.ChildNodes);
}
else
{
bool allChildChecked = true
foreach (TreeNode childNode in nodeCollection)
{
if (!childNode.Checked)
{
allChildChecked = false;
}
}
}
}
if (allChildChecked )
{
_parentNode.Checked = true;
_isAllChildChecked = false;
}
}