• TreeView只能选中一个节点


    让TreeView的所有节点包括父节点和子节点,有且仅有一个能被选中:

            private void checkAllNodes(TreeNode pNode,bool nodeChecked,TreeNodeCollection col)
            {
                if (nodeChecked == true)
                {
                    foreach (TreeNode node in col)
                    {
                        if (node != pNode)
                        {
                            node.Checked = !nodeChecked;
                        }
                        if (node.Nodes.Count > 0)
                        {
                            // If the current node has child nodes, call the checkAllNodes method recursively.
                            this.checkAllNodes(pNode,nodeChecked, node.Nodes);
                        }
                       
                    }
                }
            }

    调用: this.checkAllNodes(e.Node,e.Node.Checked, treeView1.Nodes);

  • 相关阅读:
    线程原理 创建方式
    Chapter17 【异常、线程】
    驱动
    java中Super到底是什么意思
    Java 8后的首个长期支持版本Java 11
    OpenJDK和JDK区别
    异常
    模拟斗地主洗牌发牌
    Debug追踪
    Python 垃圾回收机制详细
  • 原文地址:https://www.cnblogs.com/qingwufeiyang/p/3992237.html
Copyright © 2020-2023  润新知