I’m using WebBrowser Control for my chat application. Every time it adds user’s message – it refreshes WebBrowser with its new content. And it works good.
But after I added a background in html code it started to flicker every time it refreshes.
Here’s my Navigate() method:
public void Navigate(string url)
{
string text = File.ReadAllText(url);
if (bg.Length > 0)
webBrowser1.DocumentText = text.Replace("%bg%", "background=\"" + bg + "\"");
else
webBrowser1.DocumentText = text;
}
and this is my html file header:
addText("<html>\r\n<head>\r\n<meta charset=utf-8>\r\n</head>\r\n<body %bg% bgproperties=\"fixed\" onload=\"window.scrollTo(0,2147483647);\">\r\n<span style=\"line-height: 20px\" style=\"font-family: Arial; font-size: 14px\">\r\n<font color=black>", NewLine.No);
Every time user adds a message, my program adds it to the end of html file and executes Navigate() method.
Have you got any ideas to remove flicker?
Instead of reloading a new document every time, set the
InnerHTMLof the existingDocument.Body.