先使用Navigate("about:balnk")
方法,打开一个空页面,实际内容在IE_DocumentCompleted
中写入。代码来源于csdnreader程序。
private System.Windows.Forms.WebBrowser IE;
private string currentHtml;
private void ShowHtml(string html)
{
currentHtml=html;
//打开一个空白页,实际内容在IE_DocumentCompleted中
this.IE.Navigate("about:balnk");
}
private void IE_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//显示内容
if (e.Url.ToString() == "about:balnk")
{
this.IE.Document.Write(CurrentHtml);
}
}