.net webBrowser 控件应用

.net webBrowser 控件应用

 private string GetTNHtmlName(TreeNode tn)
        {
            int startIndex = tn.Text.LastIndexOf('(');
            int startIndex1 = tn.Text.LastIndexOf('('); ;
            int endIndex = tn.Text.LastIndexOf(')');
            int endIndex1 = tn.Text.LastIndexOf(')');

            if(startIndex1 > startIndex)
            {
                startIndex = startIndex1;
            }
            if (endIndex1 > endIndex)
            {
                endIndex = endIndex1;
            }

            if (startIndex < 0 || endIndex < 0)
            {
                return "res://" + System.Environment.SystemDirectory + @"\system32\shdoclc.dll/http_404.htm";
            }

            string url = "file://" + Application.StartupPath + "/document/" + tn.Text.Substring(startIndex + 1, endIndex - startIndex - 1) + ".htm";
            return url;
        }


        private void TVHelp_MouseClick(object sender, MouseEventArgs e)
        {
            TreeNode selTreenode = tvHelp.GetNodeAt(e.Location);
            if (e.Button == MouseButtons.Left)
            {
                if (selTreenode != null
                    && selTreenode.Nodes.Count == 0)//代表此节点是叶节点
                {
                    this.webBrowser1.Url = new Uri(GetTNHtmlName(selTreenode)) ;
                }
              
            }
        }

你可能感兴趣的:(.net webBrowser 控件应用)