Share via


WebBrowser

Click here for larger image

Windows Forms 2.0 includes a new control named the WebBrowser control that wraps Internet Explorer's ActiveX browser control. The biggest benefit of the WebBrowser control is ease of use. It enables an application to host HTML content using a simple managed object model without the need to do any interop with unmanaged code.

At design time you can easily set the WebBrowser control’s URL property. Programmatically you can perform all of the standard operations you could with the ActiveX browser control; for example, navigating the browser control and hooking navigation events. The WebBrowser control also supports several additional functions such as enabling/disabling the browser context menu and restricting what the hosted HTML page can do.

The browser control comes with a managed HTML DOM (document object model) that wraps the IE DOM. This API allows you to manipulate the hosted HTML document, listen to events, etc. The HTML DOM wrapper is not a wrapper of the full IE DOM, but instead a wrapper of the most commonly used pieces. It also supports a high degree of flexibility. For example, for HTML attributes that we may not have exposed directly, you can still get/set the attribute value using methods such as GetAttribute(string attributeName).