2010年11月15日 星期一

C# WebBrowser refresh problem

If I claim a WebBrowser object and try to add the content by the following statement:

webBrowser1.DocumentText += "new content<p>";

If we use this statement continuously in a function, like this

public void update{
    webBrowser1.DocumentText += "new content 1<p>";
    webBrowser1.DocumentText += "new content 2<p>";
}

You will see in the frame, only new content 2 show in the webBrowser1. People say the webBrowser does not refresh to screen so that only last edit would be display. (please see this C# 2.0 WebBrowser control - bug in DocumentText?http://geekswithblogs.net/paulwhitblog/archive/2005/12/12/62961.aspx)

The way to solve it is use Write to flush the content

webBrowser1.Document.Write("new content 1");

enjoy it.

沒有留言: