/// <summary> /// This method is only called when a node's state has been changed through the /// Checked property /// </summary> /// <param name="oldState">Previous state</param> /// <param name="newState">New state</param> private void CheckStateChanged(CheckState oldState, CheckState newState) { // States are equal? if (newState != oldState) { // not equal. // modify state this._nodeCheckState = newState; // change state of the children if (this.Nodes != null && this.Nodes.Count > 0) { foreach (TreeNode node in this.Nodes) { TriStateTreeNode tsNode = node as TriStateTreeNode; if (tsNode != null) { tsNode.ChangeChildState(newState); } } } // notify the parent of the changed state. if (this.Parent != null) { TriStateTreeNode parentNode = this.Parent as TriStateTreeNode; if (parentNode != null) { parentNode.ChildCheckStateChanged(this._nodeCheckState); } } } }
/// <summary> /// This method is only called by other nodes so it can be private. /// Changes state of the node to the state provided. /// </summary> /// <param name="newState"></param> private void ChangeChildState(CheckState newState) { // change state this._nodeCheckState = newState; // change state on the children if (this.Nodes != null && this.Nodes.Count > 0) { foreach (TreeNode node in this.Nodes) { TriStateTreeNode tsNode = node as TriStateTreeNode; if (tsNode != null) { tsNode.ChangeChildState(newState); } } } }