Working With a Binding Navigator Control in Windows Forms

Definition

The Binding Navigator control provides a user interface with a simple data navigation and manipulation on the form. It is used for Binding the Database Tables values to the control (DataGridView,Text Box, label and so on). The BindingNavigator with the BindingSource enable users to move through data records on a form and interact with the records.

There are a few buttons in a Binding Navigator as listed below:

  1. Move First: Go to the first record of the table
  2. Move Next: Go to the next record of the table with respect to the current record.
  3. Move Previous: Go to the previous record of the table.
  4. Move Last: Go to the last record of the table.
  5. Delete: Delete selected row (record).
  6. Add New: Add a new row.
  7. Tool Strip: You can add button, Label, Image and TextBox and so on.
  8. Position Item: current row count.
  9. Count Item: Total Number of rows in database table.

Here we bind a Binding Navigator with a DataGridView and TextBoxes. You can view the record in TextBoxes and DataGridView using the Binding Navigator. We will first create a database and table and bind the control with the Binding Navigator.

Step 1

Open your Visual Studio then select  "File" -> "New" -> "Project..." then seelct "Windows Forms Application". Then drag and drop a DataGridView, Label, Text Box and Binding Navigator control to the Form from the Toolbox as shown below:

Binding Navigator control

Step 2
  • Now open Microsoft SQL Server Studio
  • Create a table bio and insert into some values.

 Create a table

Step 3

Expand DataBindings on the top of the Binding Navigator Properties Window:
 
Binding Navigator Properties

Step 4

Click Add Project Data Source that is shown in the image above.
 
Add Project Data Source

Step 5
 
Now select Database and click the Next Button.
 
Next Button

Step 6

Select Dataset and click the Next button.
 
Select Dataset

Step 7


Click the Next Button. Select Table bio and click on the Finish button.
 
Select Table

Step 8

Open your Windows Forms form, go to the properties of the id Text Box and expand the DataBindings then seelct Text then double-click on the column id Now.
Do the same way for Name, Passw and fname also.
 
properties

Step 9

Select the BindingNavigator control and go to its properties window. Select bindingSource1.
 
BindingNavigator control properties

Step 10

Run the application by pressing F5 -> Output.
 
Run the Application

For DataGrid View

First to bind the Binding Navigator use Step 9.

Step 1
  • Select DataGridView: Now click on the smart button on the top-right of the DataGridView.
  • Select Datasource: bindingSource1. Press F5 and View the output.

output

Output

Application Output 


Similar Articles