Source Code: Multiple BindingNavigators on Same Windows Form VB 2005
Multiple BindingNavigators on Same Windows Form VB 2005
Visual Studio 2005 sometimes automatically adds a BindingNavigator for a BindingSource to a Windows form.
For example, when you drag the first DataSource to a Windows form from the DataSource panel in Visual Studio 2005, a BindingNavigator control is automatically added to the Windows form.

Result

You must sometimes manually add a BindingNavigator for a Windows Forms DataSource. For each additional DataSource you drag to the Windows form, a BindingNavigator is not automatically added.

Result

How to Manually Add a BindingNavigator for an Additional DataSource
From the Toolbox drag a BindingNavigator control to the form.

Results


Right-click the new BindingNavigator in the form components area and select Properties.
In the Properties panel rename BindingNavigator1 to a name that associates it with the BindingSource it will navigate. In the example it is the EmployeesBindingSource.

In the Properties panel set the DataSource property to the BindingSource the BindingNavigator will navigate. In the example it is the EmployeesBindingSource.

Add code to control how the two BindingNavigator controls interact with the user and the DataGridView controls on the form.. For example, you could add code to hide or show the Navigator controls depending on which DataGrid was last entered.
Private Sub CustomersDataGridView_Enter(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles CustomersDataGridView.Enter, EmployeesDataGridView.Enter
' Store the name of the DataGridView in a String type variable
' named dataGridViewName.
Dim dataGridViewName As String = CType(sender, Control).Name
' Hide all BindingNavigator controls.
Me.CustomersBindingNavigator.Hide()
Me.EmployeesBindingNavigator.Hide()
' Show the BindingNavigator control for the DataGridView
' just entered.
Select Case dataGridViewName
Case "EmployeesDataGridView"
Me.EmployeesBindingNavigator.Show()
Case "CustomersDataGridView"
Me.CustomersBindingNavigator.Show()
End Select
End Sub
Note: When you add an additional BindingNavigator control it will not have have a Save button. In the example I copied the Save button from the first BindingNavigator control (CustomerBindingNavigator) and pasted it on the second BindingNavigator (EmployeesBindingNavigator) and named the pasted button 'EmployeesBindingNavigatorSaveItem'. Then I added code to handle the new button to the form:
Private Sub EmployeesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EmployeesBindingNavigatorSaveItem.Click
Me.Validate()
Me.EmployeesBindingSource.EndEdit()
Me.EmployeesTableAdapter.Update(Me.NorthwindDataSet.Employees)
End Sub
mike mcintyre http://www.getdotnetcode.com