zoukankan      html  css  js  c++  java
  • TreeView的绑定与读取

    /// <summary>
            /// 绑定TreeView
            /// </summary>
            public void BindTreeView()
            {
                BLL.GroupBLL GroupBll = new BLL.GroupBLL();
                DataTable GroupTable = GroupBll.GetGroup();
                //先绑定根节点
                for (int i = 0; i < GroupTable.Rows.Count; i++)
                {
                    TreeNode NoteFather = new TreeNode(GroupTable.Rows[i]["Group"].ToString());
                    this.TV_Power.Nodes.Add(NoteFather);
                    this.TV_Power.Nodes[i].Value = GroupTable.Rows[i]["ID"].ToString();

                    BLL.UserBLL UserBll=new BLL.UserBLL ();
                    DataTable UserTable = UserBll.GetAllUser(Convert.ToInt32(GroupTable.Rows[i]["ID"]));
                    //再绑定子节点
                    for (int j = 0; j < UserTable.Rows.Count; j++)
                    {
                        TreeNode NoteChild = new TreeNode(UserTable.Rows[j]["Name"].ToString());
                        this.TV_Power.Nodes[i].ChildNodes.Add(NoteChild);
                        this.TV_Power.Nodes[i].ChildNodes[j].ShowCheckBox = true;
                        this.TV_Power.Nodes[i].ChildNodes[j].Value = UserTable.Rows[j]["ID"].ToString();                  
                    }
                }
            }

            StringBuilder Power = new StringBuilder();
            /// <summary>
            /// 读取TreeView节点的Value
            /// </summary>
            /// <param name="nodes"></param>
            /// <returns></returns>
            public string GetTreeViewValue(TreeNodeCollection nodes)
            {
                
                foreach (TreeNode tn in nodes)
                {
                    if (tn.Checked && tn.ChildNodes.Count == 0)
                    {
                        Power.Append(tn.Value + ",");
                    }
                    GetTreeViewValue(tn.ChildNodes);
                }
                return Power.ToString();
            }

  • 相关阅读:
    Vmware 添加虚拟磁盘
    2019-2020-2 《网络对抗技术》 Exp3 免杀原理与实践
    Docker 容器更换软件源
    Docker 查看容器 Linux 版本
    OpenMediaVault 5 进阶配置(四) Portainer 管理 Docker
    Portainer 中文文档:部署
    树莓派 部署 Docker 数据库容器
    通过Cookie统计上次网页访问时间
    用JavaMail通过QQ邮箱来发送邮件(第一篇博客,备忘)
    删掉双系统
  • 原文地址:https://www.cnblogs.com/huyueping/p/3361449.html
Copyright © 2011-2022 走看看