* 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
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 |
|
|
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
-
Set the xref:System.Windows.Forms.WebBrowser.AllowWebBrowserDrop%2A property to
falseto prevent the xref:System.Windows.Forms.WebBrowser control from opening files dropped onto it.[!code-csharpWebBrowserMisc#20] [!code-vbWebBrowserMisc#20]
-
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:
-
A xref:System.Windows.Forms.WebBrowser control named
webBrowser1. -
References to the
SystemandSystem.Windows.Formsassemblies.