How to: Create an HTML Document Viewer in a Windows Forms Application
You can use the WebBrowser control to display and print HTML documents without providing the full functionality of an Internet Web browser. This is useful when you want to take advantage of the formatting capabilities of HTML but do not want your users to load arbitrary Web pages that may contain untrusted Web controls or potentially malicious script code. You might want to restrict the capability of the WebBrowser control in this manner, for example, to use it as an HTML email viewer or to provide HTML-formatted help in your application.
To create an HTML document viewer
Set the AllowWebBrowserDrop property to
false
to prevent the WebBrowser control from opening files dropped onto it.webBrowser1.AllowWebBrowserDrop = false;
webBrowser1.AllowWebBrowserDrop = False
Set the Url property to the location of the initial file to display.
webBrowser1.Url = new Uri("http://www.contoso.com/");
webBrowser1.Url = New Uri("http://www.contoso.com/")
Compiling the Code
This example requires:
A WebBrowser control named
webBrowser1
.References to the
System
andSystem.Windows.Forms
assemblies.
See also
.NET Desktop feedback