posts - 124,  comments - 29,  trackbacks - 0

  private void InstructorTree_Load(object sender, EventArgs e)
        {
            xmlfile = Application.StartupPath + "\\CC08Help.xml";
            GetInsEvent += new GetInstructorHandle(HelpForm_GetInsEvent);
            GetHtmlEvent += new GetNodeHtml(InstructorTree_GetHtmlEvent);
            ReadXMLGetFileName();
            this.tvHelp.ImageList = this.imgLHelp;
         
            //由Excel导出的XML文档动态生成树
            if (xmlfile != "")
            {
                InitTreeView(xmlfile, this.tvHelp);
            }
            foreach (TreeNode tn in tvHelp.Nodes)
            {
                SetLeafNodeImageIndex(tn);
            }
            this.tvHelp.Nodes[0].Expand();
        }

        private TreeNode curTn = null;
    
        private void InitTreeView(string xmlfileName, TreeView tv)
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(xmlfileName);
            XmlNode xn = xdoc.SelectSingleNode("Help");
            TreeNode tn = new TreeNode();
            tn.Text = xn.ChildNodes[0].Attributes[0].Value;//命令联机帮助
            tv.Nodes.Add(tn);
            makeOutTreeView(xn.ChildNodes[0], tn);  //递归
        }

        private void makeOutTreeView(XmlNode xn,TreeNode tn)
        {
            if (xn.ChildNodes.Count != 0)
            {
                for (int i = 0; i < xn.ChildNodes.Count; i++)
                {
                    curTn = new TreeNode();
                    curTn.Text = xn.ChildNodes[i].Attributes[0].Value;
                    tn.Nodes.Add(curTn);

                    makeOutTreeView(xn.ChildNodes[i], curTn);
                }
            }
        }

posted on 2009-02-20 15:21 天书 阅读(1110) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2010年4月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜