| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
How to: Add Web Browser Capabilities to a Windows Forms Application |
03/30/2017 |
.net-framework |
|
article |
|
|
3871f072-b57a-435b-9976-e5da28df04a7 |
17 |
dotnet-bot |
dotnetcontent |
wpickett |
How to: Add Web Browser Capabilities to a Windows Forms Application
With the xref:System.Windows.Forms.WebBrowser control, you can add Web browser functionality to your application. The control works like a Web browser by default. After you load an initial URL by setting the xref:System.Windows.Forms.WebBrowser.Url%2A property, you can navigate by clicking hyperlinks or by using keyboard shortcuts to move backward and forward through navigation history. By default, you can access additional browser functionality through the right-click shortcut menu. You can also open new documents by dropping them onto the control. The xref:System.Windows.Forms.WebBrowser control also has several properties, methods, and events that you can use to implement user interface features similar to those found in Internet Explorer.
The following code example implements an address bar, typical browser buttons, a File menu, a status bar, and a title bar that displays the current page title.
Example
[!code-cppSystem.Windows.Forms.WebBrowser#0] [!code-csharpSystem.Windows.Forms.WebBrowser#0] [!code-vbSystem.Windows.Forms.WebBrowser#0]
Compiling the Code
This example requires:
- References to the
System,``System.Drawing, andSystem.Windows.Formsassemblies.
For information about building this example from the command line for [!INCLUDEvbprvb] or [!INCLUDEcsprcs], see Building from the Command Line or Command-line Building With csc.exe. You can also build this example in [!INCLUDEvsprvs] by pasting the code into a new project. Also see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.
See Also
xref:System.Windows.Forms.WebBrowser
WebBrowser Control