Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I figured this out</p> <p>I have 2 functions as follows . The first checks all the children and the second checks all the parents. Hope this helps someone. Damo</p> <pre><code>ChangeCheckedChildren(e.Node, e.Node.Checked); ChangeCheckedParents(e.Node, e.Node.Checked); /// &lt;summary&gt; /// Recursively checks or unchecks all child nodes for a given TreeNode. /// &lt;/summary&gt; /// &lt;param name="node"&gt;TreeNode to check or uncheck.&lt;/param&gt; /// &lt;param name="check"&gt;Desired value of TreeNode.Checked.&lt;/param&gt; private void ChangeCheckedChildren(TreeNode node, bool check) { try { // "Queue" up child nodes to be checked or unchecked. if (node.ChildNodes.Count &gt; 0) { for (int i = 0; i &lt; node.ChildNodes.Count; i++) ChangeCheckedChildren(node.ChildNodes[i], check); } node.Checked = check; } catch (Exception ex) { } } /// &lt;summary&gt; /// Recursively checks or unchecks all parent nodes for a given TreeNode. /// &lt;/summary&gt; /// &lt;param name="node"&gt;TreeNode to check or uncheck.&lt;/param&gt; /// &lt;param name="check"&gt;Desired value of TreeNode.Checked.&lt;/param&gt; private void ChangeCheckedParents(TreeNode node, bool check) { try { if (node.Parent == null) // if we are at the root node { if (node.ChildNodes.Count &gt; 0) { for (int i = 0; i &lt; node.ChildNodes.Count; i++) { if (node.ChildNodes[i].Checked == true) { node.Checked = true; return; } } node.Checked = false; } else { node.Checked = check; } } else { // Check all parents if the user is checking if (check == true) { node.Checked = check; ChangeCheckedParents(node.Parent, check); } else { // Do not uncheck a parent if any of its other children or their children are checked if (node.ChildNodes.Count &gt; 0) { // Default to not check and check if required node.Checked = false; for (int i = 0; i &lt; node.ChildNodes.Count; i++) { if (node.ChildNodes[i].Checked == true) { node.Checked = true; } } ChangeCheckedParents(node.Parent, check); } else { node.Checked = check; ChangeCheckedParents(node.Parent, check); } } } } catch (Exception ex) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload