zoukankan      html  css  js  c++  java
  • DevExpress控件TreeList的复选框

    DevExpress的TreeList要想在节点前面显示复选框,得修改属性OptionsView->ShowCheckBoxes=True

    DevExpress控件TreeList的复选框 - diana - 帅

    复选框的子节点与父节点统一的规则有:

    1,选择某一节点时,该节点的子节点全部选择

    2,取消某一节点时,该节点的子节点全部取消选择

    3,某节点的子节点全部选择时,该节点选择

    4,某节点的子节点未全部选择时,该节点不选择

    代码就精彩了

            private void treeList1_AfterCheckNode(object sender, NodeEventArgs e) {
                SetCheckedChildNodes(e.Node, e.Node.CheckState);
                SetCheckedParentNodes(e.Node, e.Node.CheckState);
            }
            private void treeList1_BeforeCheckNode(object sender, CheckNodeEventArgs e) {
                e.State = (e.PrevState == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked);
            }
            private void SetCheckedChildNodes(TreeListNode node, CheckState check) {
                for(int i = 0; i < node.Nodes.Count; i++) {
                    node.Nodes[i].CheckState = check;
                    SetCheckedChildNodes(node.Nodes[i], check);
                }
            }
            private void SetCheckedParentNodes(TreeListNode node, CheckState check) {
                if(node.ParentNode != null) {
                    bool b = false;
                    CheckState state;
                    for(int i = 0; i < node.ParentNode.Nodes.Count; i++) {
                        state = (CheckState)node.ParentNode.Nodes[i].CheckState;
                        if(!check.Equals(state)) {
                            b = !b;
                            break;
                        }
                    }
                    node.ParentNode.CheckState = b ? CheckState.Indeterminate : check;
                    SetCheckedParentNodes(node.ParentNode, check);
                }
            }

  • 相关阅读:
    IIS 您要访问的网页有问题,无法显示!
    windows系统添加删除用户命令!
    ASP跨域调用Webservices方法
    ASP 编码转换(乱码问题解决)
    Jquery控制滚动显示欢迎字幕v2
    iframe框架嵌套技巧(全屏,去双滚动条)
    ASP CDONTS.NEWMAIL组件发送电邮(附下载)
    ASP FORM表单提交判断
    使用js代码将HTML Table导出为Excel
    获得第二大的元素
  • 原文地址:https://www.cnblogs.com/flyhigh1860/p/2958012.html
Copyright © 2011-2022 走看看