C# winform 반복 선택TreeView 하위 노드

3605 단어 treeview
/// <summary>

        ///  

        /// </summary>

        /// <param name="nodeThis">TreeNode</param>

        private void checkAllChildNode(TreeNode nodeThis)

        {

            foreach (TreeNode childNode in nodeThis.Nodes)

            {

                childNode.Checked = nodeThis.Checked;

                if (childNode.Nodes != null)

                {

                    checkAllChildNode(childNode);

                }

            }

        }



        /// <summary>

        ///  node ( )

        /// </summary>

        /// <param name="nodeThis">node</param>

        private void checkParentNode(TreeNode nodeThis)

        {

            // 

            TreeNode parentNode = nodeThis.Parent;

            if (parentNode == null)

            {

                return;

            }

            bool isAllChecked = true;

            // 

            foreach (TreeNode node in parentNode.Nodes)

            {

                if (node.Checked != true)

                {

                    isAllChecked = false;

                    break;

                }

            }

            parentNode.Checked = isAllChecked;

            if (parentNode.Parent != null)

            {

                checkParentNode(parentNode);

            }

        }

좋은 웹페이지 즐겨찾기