You can automatically create data-bound controls with the following steps:
STEP BY STEP
8.4 Automatically Creating Data-Bound Controls
-
Select or create a form to hold data-bound controls.
-
(a). Use the left (primary) mouse button to drag a Command object from Data Environment
Designer onto the form, where it will automatically create bound controls for you, as shown
in Figure 8.10.
FIGURE 8.10 Dropping a Command object from a Data Environment Designer onto a
form to create bound controls for data fields (figure shows both the action of dragging
and the state of the form after dropping).
or
b). Use the right (alternate) mouse button to drag a Command object onto the form.
Upon releasing, you can choose the type of object to drop (DataGrid, for example),
as shown in Figure 8.11.
FIGURE 8.11 Dropping a Command object from a Data Environment Designer onto a
form to create a control bound to an entire Recordset. This figure shows both the dialog
box at the instant you drop the object and the result of the drop.
-
Test the bound controls by running the project and observing the contents of the
controls. (They should display the contents of fields in the underlying data.)
You can use the Properties window to examine the properties of a VB data-bound
object created with one of the previously discussed methods. Notice that its DataSource property
points to the Data Environment and its DataMember property points to the Command object dragged
onto the form (see Figure 8.12).

FIGURE 8.12. Data property settings of a control bound to a Data Environment's
Command object.
Consider the case of a control that is bound to an individual data field (this
could be a TextBox control that you might create in step 2a). Such a bound control's
DataField property will contain the name of the individual field from the Recordset
returned by the Command object (refer again to Figure 8.12).
See Also