VB.NET  •  Build a Web Browser

Listing 2. Whidbey offers a managed WebBrowser control. You can team this control with the new WinBar and the ProgressBar to build a Web browser that controls navigation, integrates Web access into your application, or lets the user view HTML pages.

public class frmBrowser : _
   System.Windows.Forms.Form
{
   private TextBox txtURL ;
      private System.Windows.Forms.WinBar _
         winBar1;
   private System.Windows.Forms.FlowLayoutPanel _
      flowLayoutPanel1;
   private System.Windows.Forms.WinBarTextBox _
      wbtxtURL;
   private System.Windows.Forms.WinBarButton _
      wbbtnGo;
   private System.Windows.Forms.WebBrowser _
      webBrowser;
   private System.Windows.Forms.ProgressBar _
      progressBar;
<clipped standard Windows.Forms stuff>
   [STAThread]
   static void Main()
   {
      Application.EnableVisualStyles();
      Application.Run(new frmBrowser());
   }

   private void frmBrowser_Load(object sender, _
      System.EventArgs e)
   {
      txtURL = this.wbtxtURL.TextBox;
   this.txtURL.KeyUp += new _
      System.Windows.Forms.KeyEventHandler( _
      this.txtURL_KeyUp); 
   txtURL.AutoCompleteMode = _
      AutoCompleteMode.AutoSuggestAppend;
   txtURL.AutoCompleteSource = _
      AutoCompleteSource.AllUrl;
   }

   private void txtURL_KeyUp(object sender, _
      System.Windows.Forms.KeyEventArgs e)
   {
      if (e.KeyData == Keys.Return)
      {
      this.wbbtnGo.Focus();
      Go();
      }
   }

   private void wbbtnGo_Click(object sender, _
      System.EventArgs e)
   {
   Go();
   }

   private void webBrowser_ProgressChanged( _
      object sender, System.Windows.Forms. _
      WebBrowserProgressChangedEventArgs e)
   {
this.progressBar.Value = (Int32)e.CurrentProgress;
   }

   private void Go()
   {
      webBrowser.Navigate(wbtxtURL.Text);
   }
}