---
title: Create an HTML Document Viewer in a Windows Forms app
titleSuffix: ""
ms.date: "03/30/2017"
dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "WebBrowser control [Windows Forms], creating an HTML document viewer"
- "document viewers"
- "Windows Forms, creating document viewers"
ms.assetid: 6a6338fe-f7ee-4f5e-9d8f-0465c57e9039
---
# How to: Create an HTML Document Viewer in a Windows Forms Application
You can use the 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 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
1. Set the property to `false` to prevent the control from opening files dropped onto it.
[!code-csharp[WebBrowserMisc#20](~/samples/snippets/csharp/VS_Snippets_Winforms/WebBrowserMisc/CS/WebBrowserMisc.cs#20)]
[!code-vb[WebBrowserMisc#20](~/samples/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb#20)]
2. Set the property to the location of the initial file to display.
[!code-csharp[WebBrowserMisc#21](~/samples/snippets/csharp/VS_Snippets_Winforms/WebBrowserMisc/CS/WebBrowserMisc.cs#21)]
[!code-vb[WebBrowserMisc#21](~/samples/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb#21)]
## Compiling the Code
This example requires:
- A control named `webBrowser1`.
- References to the `System` and `System.Windows.Forms` assemblies.
## See also
-
-
-
- [WebBrowser Control Overview](webbrowser-control-overview.md)
- [WebBrowser Security](webbrowser-security.md)
- [How to: Navigate to a URL with the WebBrowser Control](how-to-navigate-to-a-url-with-the-webbrowser-control.md)
- [How to: Print with a WebBrowser Control](how-to-print-with-a-webbrowser-control.md)