How to display the string html contents into webbrowser control?

前端 未结 9 1581
不知归路
不知归路 2020-11-27 06:47

I have a c# win app program. I save the text with html format in my database but I want to show it in a webbrowser to my user.How to display the string html contents into we

9条回答
  •  心在旅途
    2020-11-27 07:18

    For some reason the code supplied by m3z (with the DisplayHtml(string) method) is not working in my case (except first time). I'm always displaying html from string. Here is my version after the battle with the WebBrowser control:

    webBrowser1.Navigate("about:blank");
    while (webBrowser1.Document == null || webBrowser1.Document.Body == null)
        Application.DoEvents();
    webBrowser1.Document.OpenNew(true).Write(html);
    

    Working every time for me. I hope it helps someone.

提交回复
热议问题