Esempio n. 1
0
        private void btnUseDefautTree_Click(object sender, EventArgs e)
        {
            TreeNodeItem node1 = new TreeNodeItem();
            XmlTreeNode  list  = XmlTreeNode.LoadFromXml();

            list.Sort();
            if (list != null)
            {
                DataTable dt = list.GetListNode();
                DataRow[] dr = dt.Select("fname ='root'");
                if (dr.Length > 0)
                {
                    for (int i = 0; i < dr.Length; i++)
                    {
                        string       aclid    = dr[i]["ACLID"].ToString();
                        TreeNodeItem item     = list.GetItemByAclid(aclid);
                        TreeNode     treeNode = new TreeNode();
                        treeNode.Text = item.Descript;
                        treeNode.Tag  = item;
                        //创建子节点
                        CreateChildNode(treeNode, list, dt, aclid);

                        treeView1.Nodes.Add(treeNode);
                    }
                }
            }
            else
            {
                list = new XmlTreeNode();
                for (int i = 0; i < 5; i++)
                {
                    node1          = new TreeNodeItem();
                    node1.Descript = "descript" + i;
                    node1.Name     = "name" + i;
                    node1.FName    = "root";
                    node1.DllName  = "dllName" + i;
                    node1.Aclid    = Guid.NewGuid().ToString();
                    list.listNode.Add(node1);
                }
                for (int i = 0; i < 5; i++)
                {
                    node1          = new TreeNodeItem();
                    node1.Descript = "node descript" + i;
                    node1.Name     = "name" + i;
                    node1.FName    = "name" + i;
                    node1.DllName  = "dllName" + i;
                    node1.Aclid    = Guid.NewGuid().ToString();
                    list.listNode.Add(node1);
                }
            }
            XmlTreeNode.SaveToXml(list);
        }