In year 2001, I wrote an article on how to use IE Browser ActiveX control in your Windows Forms applications using COM Interop.
Now Windows Forms 2.0 (ships with Visual Studio 2005) comes with a Windows Forms Web Browser control, which is again is a wrapper of IE ActiveX control. This control is available in Visual Studio 2005 Toolbox. See Figure 1.
Figure 1. WebBrowser control in Toolbox
To add this control to your application, just drag and drop on the form. Now I add a TextBox and a Button control to the Form, change their Name and Text properties, and write the following code on the button click event handler. private void BrowseBtn_Click(object sender, EventArgs e)
webBrowser1.Url = UrlTextBox.Text;
Now run the application, type a URL in the TextBox and click the button. The output is Figure 2.
Figure 2. Using WebBrowser control
WebBrowser control is represented by System.Windows.Forms.WebBrowser class.
In this control, you can set some properties such as IsWebWebBrowserContextMenuEnabled, SecurityLevel, and WebBrowserShortcutEnabled. See Figure 3.
Figure 3. WebBrowser control properties.
Personally, I am really not fond about this control. What I would really like to see in this control was to have property to show URL TextBox and button built-in the control itself. So as a programmer, if I wanted the URL TextBox to be displayed, I would simply set the property.
Other features I would like see in this control could be all the features IE and other browsers provide. I guess Microsoft always leaves something for us programmers to do ;).