• 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

  • 相关阅读:
    字符串-01. 在字符串中查找指定字符(15)
    数组-14. 数字加密(15)
    软考笔记第一天之数制
    基于c#开发的简易点名器
    软考笔记之存储管理
    IO inputStream和outputStream
    java可变参数
    Map集合总结
    Collection集合总结
    Struts 获得前台传参几种方式
  • 原文地址:https://www.cnblogs.com/guojingmail2009/p/3481718.html
Copyright © 2020-2023  润新知