System.Windows.Forms.TreeNode.Collapse C# (CSharp) Method

Collapse() public method

public Collapse ( ) : void
return void
        public void Collapse()
        {
            expanded = false;
            TreeView.Refresh();
        }

Usage Example

Example #1
0
        private static void SetNodeStyle(TreeNode Node)
        {
            int nNodeCount = 0;
            if (Node.Nodes.Count != 0)
            {
                foreach (TreeNode tnTemp in Node.Nodes)
                {

                    if (tnTemp.Checked == true)

                        nNodeCount++;
                }

                if (nNodeCount == Node.Nodes.Count)
                {
                    Node.Checked = true;
                    Node.ExpandAll();
                    Node.ForeColor = Color.Black;
                }
                else if (nNodeCount == 0)
                {
                    Node.Checked = false;
                    Node.Collapse();
                    Node.ForeColor = Color.Black;
                }
                else
                {
                    Node.Checked = true;
                    Node.ForeColor = Color.Gray;
                }
            }
            //当前节点选择完后,判断父节点的状态,调用此方法递归。
            if (Node.Parent != null)
                SetNodeStyle(Node.Parent);
        }
All Usage Examples Of System.Windows.Forms.TreeNode::Collapse