Creating a Simple-Bound Control on a Windows Form
Simple binding allows you to display a single data element, such as a column value from a dataset table, in a control. You can simple-bind any property of a control to a data value.
To simple-bind a control
- Connect to a data source. For details, see Connecting to Data Sources with ADO.NET.
- In the form, select the control and display the Properties window.
- Expand the (DataBindings) property.
The properties most often bound are displayed underneath the (DataBindings) property. For example, in most controls, the Text property is most frequently bound.
- If the property you want to bind is not one of the commonly bound properties, click the Ellipsis button () in the (Advanced) box to display the Advanced Data Binding dialog box with a complete list of properties for that control.
- Click the drop-down arrow for the property you want to bind.
A list of available data sources is displayed.
- Expand the data source you want to bind to until you find the single data element you want. For example, if you are binding to a column value in a dataset's table, expand the name of the dataset, and then expand the table name to display column names.
- Click the name of an element to bind to.
- If you were working in the Advanced Data Binding dialog box, click Close to return to the Properties window.
- If you want to bind additional properties of the control, repeat steps 3 through 7.
Because simple-bound controls show only a single data element, it is very typical to include navigation logic in a Windows Form with simple-bound controls. For an example of a complete form that includes both simple-bound controls and navigation, see Walkthrough: Simple Data Access in a Windows Form.