Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-create-an-html-document-viewer-in-a-windows-forms-application.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

2.5 KiB

title, titleSuffix, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title titleSuffix ms.date dev_langs helpviewer_keywords ms.assetid
Create an HTML Document Viewer in a Windows Forms app 03/30/2017
csharp
vb
WebBrowser control [Windows Forms], creating an HTML document viewer
document viewers
Windows Forms, creating document viewers
6a6338fe-f7ee-4f5e-9d8f-0465c57e9039

How to: Create an HTML Document Viewer in a Windows Forms Application

You can use the xref:System.Windows.Forms.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 xref:System.Windows.Forms.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

  1. Set the xref:System.Windows.Forms.WebBrowser.AllowWebBrowserDrop%2A property to false to prevent the xref:System.Windows.Forms.WebBrowser control from opening files dropped onto it.

    [!code-csharpWebBrowserMisc#20] [!code-vbWebBrowserMisc#20]

  2. Set the xref:System.Windows.Forms.WebBrowser.Url%2A property to the location of the initial file to display.

    [!code-csharpWebBrowserMisc#21] [!code-vbWebBrowserMisc#21]

Compiling the Code

This example requires:

See also