After you have added controls to your form and determined the user interface for your application, you can bind the controls to a data source, so that, at run time, users can alter and save data related to the application.
Binding a control or series of controls in Windows Forms is most easily accomplished using the BindingSource control as a bridge between the controls on the form and the data source.
One or more controls on a form can be bound to data; in the following procedure, a TextBox control is bound to a data source.
To complete the procedure, it is assumed that you will bind to a data source derived from a database. For more information on creating data sources from other stores of data, see Add new data sources.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.
To bind a control at design time
Drag a TextBox control on to the form.
In the Properties window:
Expand the (DataBindings) node.
Click the arrow next to the Text property.
The DataSource UI type editor opens.
If a data source has previously been configured for the project or form, it will appear.
Click Add Project Data Source to connect to data and create a data source.
On the Data Source Configuration Wizard welcome page, click Next.
On the Choose a Data Source Type page, select Database.
On the Choose Your Data Connection page, select a data connection from the list of available connections. If your desired data connection is not available select New Connection to create a new data connection.
Select Yes, save the connection to save the connection string in the application configuration file.
Select the database objects to bring into your application. In this case, select a field in a table that you would like the TextBox to display.
Replace the default dataset name if you want.
The DataSource UI type editor closes and the data set, BindingSource and table adapter specific to that data connection are added to your form.