Requirements for selecting nodes in the TreeView tree:
1. If no node is selected, all its subnodes are not selected.
2. If a node is selected, all its subnodes are selected.
3. If no subnode of a node is selected, the node is not selected.
4. When one of all the child nodes of a node is selected, the node is also selected.
In the code, the event parameter e. the Action can avoid entering AfterCheck () again when changing the Checked status of the node. In this way, when there are other logical responses in AfterCheck (), you can check the status each time, other logics only respond once.
Reference code:
TreeView_AfterCheck (e. action = TreeViewAction. byMouse | e. action = SetChildNodeCheckedState (TreeNode currNode, (currNode. nodes =); (TreeNode tmpNode = SetParentNodeCheckedState (TreeNode currNode, (currNode. parent =); (isCheckedOrNot) = checkedFlag = (TreeNode tmpNode =