示例#1
0
        /// <summary>
        /// 动态绑定TreeView,这里只限XML树为三级。
        /// </summary>
        private void BindTree(Crownwood.DotNetMagic.Controls.TreeControl treeControl, XmlDocument _xmldoc)
        {
            XmlNodeList _list = _xmldoc.DocumentElement.ChildNodes;

            foreach (XmlElement elem in _list)
            {
                string strText = elem.Attributes["name"].Value;
                Crownwood.DotNetMagic.Controls.Node treeNode = new Crownwood.DotNetMagic.Controls.Node(strText);

                XmlNodeList clist = elem.ChildNodes;
                if (clist.Count > 0)
                {
                    foreach (XmlElement celem in clist)
                    {
                        if (celem.ChildNodes.Count > 0)
                        {
                            string cText = celem.Attributes["name"].Value;
                            Crownwood.DotNetMagic.Controls.Node ctreeNode = new Crownwood.DotNetMagic.Controls.Node(cText);
                            ctreeNode.Tag = null;
                            treeNode.Nodes.Add(ctreeNode);
                            foreach (XmlElement elem3 in celem.ChildNodes)
                            {
                                string ctext3 = elem3.Attributes["name"].Value;
                                string url    = elem3.Attributes["url"].Value;
                                if (Com.UserInfo.htRights.ContainsKey(url) || Com.UserInfo.eIBase == "1")
                                {
                                    Crownwood.DotNetMagic.Controls.Node ctreeNode3 = new Crownwood.DotNetMagic.Controls.Node(ctext3);
                                    ctreeNode3.Tag = elem3.Attributes["url"].Value
                                                     + "&" + elem3.Attributes["class"].Value
                                                     + (elem3.Attributes.Count > 3 ? ("&" + elem3.Attributes["baseForm"].Value) : "");
                                    ctreeNode.Nodes.Add(ctreeNode3);
                                }
                            }
                        }
                        else
                        {
                            string cText = celem.Attributes["name"].Value;
                            string url   = celem.Attributes["url"].Value;
                            if (Com.UserInfo.htRights.ContainsKey(url) || Com.UserInfo.eIBase == "1")
                            {
                                Crownwood.DotNetMagic.Controls.Node ctreeNode = new Crownwood.DotNetMagic.Controls.Node(cText);
                                ctreeNode.Tag = celem.Attributes["url"].Value
                                                + "&" + celem.Attributes["class"].Value
                                                + (celem.Attributes.Count > 3 ? ("&" + celem.Attributes["baseForm"].Value) : "");
                                treeNode.Nodes.Add(ctreeNode);
                            }
                        }
                    }
                }
                if (treeNode.Nodes.Count > 0)
                {
                    treeControl.Nodes.Add(treeNode);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 动态绑定TreeView,这里只限XML树为三级。
        /// </summary>
        private void BindTree(Crownwood.DotNetMagic.Controls.TreeControl treeControl, XmlDocument _xmldoc)
        {
            XmlNodeList _list = _xmldoc.DocumentElement.ChildNodes;

            foreach (XmlElement elem in _list)
            {
                string strText = elem.Attributes["name"].Value;
                Crownwood.DotNetMagic.Controls.Node treeNode = new Crownwood.DotNetMagic.Controls.Node(strText);
                treeControl.Nodes.Add(treeNode);
                XmlNodeList clist = elem.ChildNodes;
                if (clist.Count > 0)
                {
                    foreach (XmlElement celem in clist)
                    {
                        if (celem.ChildNodes.Count > 0)
                        {
                            string cText = celem.Attributes["name"].Value;
                            Crownwood.DotNetMagic.Controls.Node ctreeNode = new Crownwood.DotNetMagic.Controls.Node(cText);
                            ctreeNode.Tag = null;
                            treeNode.Nodes.Add(ctreeNode);
                            foreach (XmlElement elem3 in celem.ChildNodes)
                            {
                                string ctext3 = elem3.Attributes["name"].Value;
                                Crownwood.DotNetMagic.Controls.Node ctreeNode3 = new Crownwood.DotNetMagic.Controls.Node(ctext3);
                                ctreeNode3.Tag = elem3.Attributes["url"].Value + "&" + elem3.Attributes["class"].Value;
                                ctreeNode.Nodes.Add(ctreeNode3);
                            }
                        }
                        else
                        {
                            string cText = celem.Attributes["name"].Value;
                            Crownwood.DotNetMagic.Controls.Node ctreeNode = new Crownwood.DotNetMagic.Controls.Node(cText);
                            ctreeNode.Tag = celem.Attributes["url"].Value + "&" + celem.Attributes["class"].Value;
                            treeNode.Nodes.Add(ctreeNode);
                        }
                    }
                }
            }
        }