• 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;
        }

  • 相关阅读:
    最小生成树(模板)
    排序
    kmp模板
    图书管理系统
    顺序表的创建
    洛谷p1090合并果子(优先队列或堆)
    洛谷P1464Function(逆向递推递归+记忆化)
    ueditor设置
    php isset()和 in_array()
    php 判断空
  • 原文地址:https://www.cnblogs.com/hyd309/p/1292804.html
Copyright © 2020-2023  润新知