As discussed in the In Depth section of this chapter, simple binding lets you display one data element, such as a field's value from a data table, in a control. In Visual Basic .NET, you can simple-bind any property of a control to a data value.
At design time, for example, to bind a text box's Text property to the au_lname field in the authors table from the pubs database in a dataset, you select the text box and expand its (DataBindings) property in the Properties window. You'll see the most commonly bound properties already listed, such as the Tag and Text properties for a text box, as shown in Figure 21.1. You can select a field in a dataset to bind to just by clicking a property and selecting a table from the drop-down list that appears.
You also can bind to any property of a control, and to do that, click the ellipsis button that appears when you click the (Advanced) entry in the (DataBindings) property, opening the Advanced Data Binding dialog you see in Figure 21.2.
You also can perform simple binding in code, using a control's DataBindings property (see the "Using the DataBindings Property for Data Binding" solution), which holds a collection of Binding objects (see the "Using the Binding Class" solution in this chapter) corresponding to the bindings for the control. For example, as we saw in the In Depth section of this chapter, to bind the text box to the same au_lname field that we just bound it to at design time, we could do this in code, using the collection's Add method; you pass this method the property to bind, the data source to use, and the specific field you want to bind:
TextBox1.DataBindings.Add("Text", DataSet11, "authors.au_lname")
For more information on simple binding, see the In Depth section of this chapter.