zoukankan      html  css  js  c++  java
  • DevExpress之Treelist应用

            /// <summary>
            /// 设置节点状态
            /// </summary>
            /// <param name="nodes">TreeListNodes</param>
            /// <param name="bcheck">是否选中</param>
            private void NodeCheck(TreeListNodes nodes, bool bcheck)
            {
                foreach (TreeListNode node in nodes)
                {
                    node.Checked = bcheck;
                    if (node.HasChildren)
                    {
                        NodeCheck(node.Nodes, bcheck);
                    }
                }
            }

    动态生成节点

                var onevalue = new object[] { "0", "0", "0" };
                DevExpress.XtraTreeList.Nodes.TreeListNode oneNode = treeList1.AppendNode(onevalue, null);//添加一级节点
    
                for (int i = 1; i < 5; i++)
                {
                    var teovalue = new object[] { i.ToString(), i.ToString(), i.ToString() };
    
                    this.treeList1.AppendNode(teovalue, oneNode);
    
                }
    
                for (int i = 10; i < 15; i++)
                {
                    for (int j = 0; j < treeList1.Nodes[0].Nodes.Count; j++)
                    {
                        if (treeList1.Nodes[0].Nodes[j].GetValue("treeListColumn1").ToString() == "2")
                        {
                            var trridvalue = new object[] { (i * 10).ToString(), (i * 10).ToString(), (i * 10).ToString() };
                            this.treeList1.AppendNode(trridvalue, treeList1.Nodes[0].Nodes[j]);
                        }
                    }
                }
    
                for (int i = 16; i < 20; i++)
                {
                    for (int j = 0; j < treeList1.Nodes[0].Nodes.Count; j++)
                    {
                        if (treeList1.Nodes[0].Nodes[j].GetValue("treeListColumn1").ToString() == "3")
                        {
                            var trridvalue = new object[] { (i * 10).ToString(), (i * 10).ToString(), (i * 10).ToString() };
                            this.treeList1.AppendNode(trridvalue, treeList1.Nodes[0].Nodes[j]);
                        }
                    }
                }
            /// <summary>
            /// 根据列名和值查找节点
            /// </summary>
            /// <param name="nodes"></param>
            /// <param name="colname"></param>
            /// <param name="colvalue"></param>
            /// <returns></returns>
            private TreeListNode GetNodeByCol(TreeListNodes nodes, string colname, string colvalue)
            {
                foreach (TreeListNode node in nodes)
                {
                    string svalue = node.GetValue(colname).ToString();
                    if (svalue == colvalue)
                    {
                        return node;
                    }
                    if (node.HasChildren)
                    {
                        GetNodeByCol(node.Nodes, colname, colvalue);
                    }
                }
                return null;
            }
  • 相关阅读:
    debian8 vga 文本模式下出现闪屏
    Delphi中根据分类数据生成树形结构的最优方法
    SQL获取每月、每季度、每年的最后一天记录
    Delphi实现树型结构
    Delphi中initialization和finalization
    Delphi 连接 Paradox
    delphi2007单个文件(pas)的控件安装
    Delphi安装*.pas扩展名的控件
    数据库组件介绍(Delphi)
    Delphi控件开发浅入深出(三)
  • 原文地址:https://www.cnblogs.com/leebokeyuan/p/11950944.html
Copyright © 2011-2022 走看看