(c) 2003 Visual Studio Magazine 
Fawcette Technical Publications

VB.NET	Implement WinBar Behavior
Listing 1	This code implements the VCR control's basic features in a data form's WinBar by calling methods and properties of the DataContainer. The DataContainer includes most of the behavior you're likely to want to add to data forms.

Private Sub wbbtnFirst_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnFirst.Click
	Me.dcCustomers.MoveFirst()
End Sub

Private Sub wbbtnPrevious_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnPrevious.Click
	Me.dcCustomers.MovePrevious()
End Sub

Private Sub wbbtnNext_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnNext.Click
	Me.dcCustomers.MoveNext()
End Sub

Private Sub wbbtnLast_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
`wbbtnLast.Click
	Me.dcCustomers.MoveLast()
End Sub

Private Sub wbbtnPageDown_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnPageDown.Click
	Me.dcCustomers.Position += _
		Me.grdCustomers.DisplayedRowCount(False)
End Sub

Private Sub wbbtnPageUp_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnPageUp.Click
	Me.dcCustomers.Position -= _
		Me.grdCustomers.DisplayedRowCount(False)
End Sub

Private Sub dcCustomers_PositionChanged(_
	ByVal sender As Object, ByVal e As _
	System.EventArgs) Handles _
	dcCustomers.PositionChanged
	Me.wbtextPosition.Text = _
		CStr(Me.dcCustomers.Position + 1) & _
		" of " & CStr( _
		Me.dcCustomers.CurrencyManager.Count)
End Sub

Private Sub wbbtnFill_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnFill.Click
	Me.dcCustomers.LoadData()
End Sub

Private Sub wbbtnUndo_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs)
	Me.dcCustomers.CancelEdit()
End Sub

Private Sub wbbtnNew_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnNew.Click
	Me.dcCustomers.AddNew()
End Sub

Private Sub wbbtnDelete_Click(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	wbbtnDelete.Click
	Me.dcCustomers.Delete()
End Sub

Private Sub frmCustomer_Load(ByVal sender As _
	Object, ByVal e As System.EventArgs) Handles _
	MyBase.Load
	Application.EnableVisualStyles()
End Sub


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);
	}
}

