zoukankan      html  css  js  c++  java
  • treeview 的深层添加节点

       private void SetTree()       //设置treeview 数据绑定
        {
            TreeView.Nodes.Clear();
            BM1.IBLL.IFileRgstBLL bll = BM1.Factory.BLLFactory.CreateIFileRgstBLL();
            ArrayList list = bll.GetPath(Session["CMP_ID"].ToString(), false,Session["LANGUAGE"].ToString(), 0);

            TreeNode Parent = new TreeNode("文档管理","Root");

            for (int i = 0; i < list.Count; i++ )
            {
                FileRgstVO vo = (FileRgstVO)list[i];
                if (vo.GetParent_Num == 0)
                {
                    Parent.ChildNodes.Add(new TreeNode(vo.GetPath_Name, vo.GetPath_Num.ToString()));
                    continue;
                }
                //Parent = aa(vo, Parent);
                //递归调用添加子节点
                aa(vo, Parent);
            }
            TreeView.Nodes.Add(Parent);
        }

        private bool aa(FileRgstVO vo , TreeNode treeNode)  //遍历添加子节点
        {
            if (vo.GetParent_Num.ToString() == treeNode.Value)
            {
                treeNode.ChildNodes.Add(new TreeNode(vo.GetPath_Name, vo.GetPath_Num.ToString()));
                return true;
            }
            bool flg = false;

            foreach (object obj in treeNode.ChildNodes)
            {
                TreeNode tree = (TreeNode)obj;
                if (vo.GetParent_Num.ToString() == tree.Value)
                {
                    tree.ChildNodes.Add(new TreeNode(vo.GetPath_Name, vo.GetPath_Num.ToString()));
                    flg = true;
                    break;
                }
                else
                {
                    flg = aa(vo, tree);
                    if (flg)
                        break;
                }
            }
            return flg;
        }

  • 相关阅读:
    Vue使用watch监听一个对象中的属性
    小程序 显示对话框 确定-取消
    【微信小程序】 wx:if 与 hidden(隐藏元素)区别
    vue项目移植tinymce踩坑
    XMLHttpRequest.withCredentials 解决跨域请求头无Cookie的问题
    appJSON["window"]["navigationBarTextStyle"] 字段需为 black 或 white
    Java写 插入 选择 冒泡 快排
    编码表理解
    Centos yum安装java jdk1.8
    Java Hibernate和.Net EntityFramework 如何在提交事务之前 就拿到需要新增实体的Id
  • 原文地址:https://www.cnblogs.com/hyd309/p/1292804.html
Copyright © 2011-2022 走看看