In this article I will explain with an example, how to load and display HTML string in WebBrowser control in Windows Application (Windows Forms Application) using C# and VB.Net.
 
 
Form Controls
The following Form consists of a WebBrowser control.
Load and display HTML string in WebBrowser control in Windows Application using C# and VB.Net
 
 
Load and display HTML string in WebBrowser control in Windows Application
Inside the Form Load event handler, the HTML string is generated and it is assigned to the DocumentText property of the WebBrowser control.
C#
private void Form1_Load(object sender, EventArgs e)
{
    string html = "<font face='arial' size='3'>Hello,<br />My name is ";
    html += "<b style = 'color:red'>Mudassar Khan</b>.</font>";
    html += "<hr /><img src='https://www.aspsnippets.com/images/authors/Mudassar.png' />";
    webBrowser1.DocumentText = html;
}
 
VB.Net
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim html As String = "<font face='arial' size='3'>Hello,<br />My name is "
    html += "<b style = 'color:red'>Mudassar Khan</b>.</font>"
    html += "<hr /><img src='https://www.aspsnippets.com/images/authors/Mudassar.png' />"
    webBrowser1.DocumentText = html
End Sub
 
 
Screenshot
Load and display HTML string in WebBrowser control in Windows Application using C# and VB.Net
 
 
Downloads