0

您好,我正在使用此代码:

    private void Form1_Load(object sender, EventArgs e)
    {
        webBrowser1.Navigate("about:blank");

        HtmlDocument doc = webBrowser1.Document;
        doc.Write("<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.");
    }
    private void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate("about:blank");
        HtmlDocument doc = webBrowser1.Document;
        doc.Write("<b><i>My Name</i> is Not </b> Khan.<b>");
    }

但是当我点击按钮时,webBrowser1 显示为空白。

4

1 回答 1

0

试试下面的代码:

    private void Form1_Load(object sender, EventArgs e)
    {
        string strText = "<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.";
        webBrowser1.Navigate("about:blank");
        HtmlDocument objHtmlDoc = this.webBrowser1.Document;
        objHtmlDoc.Write(String.Empty);
        webBrowser1.DocumentText = strText;
    }
    private void button1_Click(object sender, EventArgs e)
    {
        string strText="<b><i>My Name</i> is Not </b> Khan.<b>";
        webBrowser1.Navigate("about:blank");
        HtmlDocument objHtmlDoc = this.webBrowser1.Document;
        objHtmlDoc.Write(String.Empty);
        webBrowser1.DocumentText = strText;
    }
于 2013-02-20T14:21:25.817 回答