Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Binding VB Objects to Data Environment Objects in Visual Basic 6

You can automatically create data-bound controls with the following steps:

STEP BY STEP
8.4 Automatically Creating Data-Bound Controls

  1. Select or create a form to hold data-bound controls.

  2. (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.

    Dropping a Command object from a Data Environment Designer onto a form to create bound controls for data fields
    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.

    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.
    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.

  3. 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).

Data property settings of a control bound to a Data Environment's Command object.
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

 


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved