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:
- Move First: Go to the first record of the table
- Move Next: Go to the next record of the table with respect to the current record.
- Move Previous: Go to the previous record of the table.
- Move Last: Go to the last record of the table.
- Delete: Delete selected row (record).
- Add New: Add a new row.
- Tool Strip: You can add button, Label, Image and TextBox and so on.
- Position Item: current row count.
- 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:
Step 2
- Now open Microsoft SQL Server Studio
- Create a table bio and insert into some values.
Step 3
Expand DataBindings on the top of the Binding Navigator Properties Window:
Step 4Click Add Project Data Source that is shown in the image above.
Step 5 Now select Database and click the Next Button.
Step 6Select Dataset and click the Next button.
Step 7Click the Next Button. Select Table bio and click on the Finish button.
Step 8Open 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.
Step 9Select the BindingNavigator control and go to its properties window. Select bindingSource1.
Step 10Run the application by pressing F5 -> Output.
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