WebBrowser Control.
The Windows.Forms.WebBrowser control can be used within applications to allow the
user to surf the internet and open web enabled documents like html help files, word
documents etc.
The control is a basic webbrowser control and is by no means perfect. When using
the control for surfing the internet, you will notice that it does not respond to
Flash objects correctly. With the Flash objects, the control will only rspond once
(click) on the Flash object.
The control includes several navigation methods or functions as: Url ,Navigate ,GoBack
,GoForward ,GoHome, GoSearch.
Namespace: System.Windows.Forms
Assembly: Systems.Windows.Forms.dll
using System.Windows.Forms;
Calling: System.Windows.Forms.WebBrowser
Creating a new System.Windows.Forms.WebBrowser control.
WebBrowser webBrowser1 = new WebBrowser();
To add the WebBrowser control to the form.
this.Controls.Add(webBrowser1);
To fill the form with the WebBrowser control.
webBrowser1.Dock = DockStyle.Fill;
To disable keyboard short cuts for theWebBrowser control.
webBrowser1.WebBrowserShortcutsEnabled = false;
To navigate the webBrowser control to a specific webpage.
webBrowser1.Navigate("http://www.speakcomputers.com");
To create the DocumentCompleted event handler.
webBrowser1.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
To respond to the DocumentCompleted event.
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs
e) { comboBox1.Text = webBrowser1.Url.ToString(); }
WebBrowser Navigation:
To navigate back to the previous page. (If the webBrowser can navigate back).
if (webBrowser1.CanGoBack) { webBrowser1.GoBack(); }
To navigate forward (If the webBrowser can navigate forward).
if (webBrowser1.CanGoForward) { webBrowser1.GoForward(); }
To navigate to your home page.
webBrowser1.GoHome();
Creating a Tabbed WebBrowser.
Download the source code
for a basic tabbed WebBrowser (Beginner Level).
In this project, we make use of the Windows TabControl and the System.Windows.Forms.WebBrowser
control. We show you how to create runtime Tabbed Webbrowsers with events and how
to respond to these events, how to reference these WebBrowser controls, the navigation
of the webBrowser controls and menu items. Requirements: VisualStudio 2005.
Infragistics.
Infragistics controls do not include the WebBrowser control as yet. A fully completed
WebBrowser control which would include all the standard navigation controls, better
looking context menu, a fix for the Flash problem and the complete style set with
mdi mergable tools would really compliment the control set.
|