zoukankan      html  css  js  c++  java
  • C# winform treeView checkbox全选反选

    private void treeView2_AfterCheck(object sender, TreeViewEventArgs e)
            {
                if (e.Action != TreeViewAction.Unknown)
                {
                    CheckAllChildNodes(e.Node, e.Node.Checked);
                    //选中父节点 
                    bool bol = true;
                    if (e.Node.Parent != null)
                    {
                        for (int i = 0; i < e.Node.Parent.Nodes.Count; i++)
                        {
                            if (!e.Node.Parent.Nodes[i].Checked)
                                bol = false;
                        }
                        e.Node.Parent.Checked = bol;
                    }
                }
            }
            #region  选中子节点
            public void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
            {
                foreach (TreeNode node in treeNode.Nodes)
                {
                    node.Checked = nodeChecked;
                    if (node.Nodes.Count > 0)
                    {
                        this.CheckAllChildNodes(node, nodeChecked);
                    }
                }
            }
            #endregion

  • 相关阅读:
    spring学习(十七)--annotion注解
    spring学习(十六)--spring方式实现工程初始化配置
    spring学习(十五)--自己实现BeanFactory
    JDBC使用SPI机制解析
    SPI机制
    spring学习(十三)--自己实现SpringServletContainerInitializer
    cetnos基本操作
    CentOS基本命令
    面向对象的双下方法
    Flask数据连接池 DBUtils
  • 原文地址:https://www.cnblogs.com/guojingmail2009/p/3481718.html
Copyright © 2011-2022 走看看