How do you put html on WebBrowser WinForms?



  • The image of the html file in the WebBrowser element, MSDN articles read but are not available. How do you get the code?



    1. Read the file in the line - challenge. File.ReadAllText(filename);
    2. display contents WebBrowser equal to that line - through its properties DocumentText:

      webBrowser1.DocumentText = "<html><body>Hello, World!</body></html>"
      

    Statement DocumentText It only works once. If you need to change the contents several times, use the following code:

    private void DisplayHtml(string html)
    {
        webBrowser1.Navigate("about:blank");
        if (webBrowser1.Document != null)
        {
            webBrowser1.Document.Write(string.Empty);
        }
        webBrowser1.DocumentText = html;
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2