Visual Basic Concepts

Forms and Data-Aware Controls

See Also

To create interfaces for data entry, data editing, or data viewing, Visual Basic forms and controls have always offered versatility and ease of programming.

In version 6.0, several new data-aware (data-bound) controls have been added. In addition to these new controls, the new Validate event and CausesValidation property prevent a control from losing focus until all data has been validated. For example, you can create data-entry forms that validate data by preventing the user from tabbing off the form until all fields have been filled in.

Another enhancement always available to you is the Microsoft Data Formatting Object Library. This new object library allow you to format data and preserve the underlying format to write back to the database.

New Data-Aware Controls

Several new ActiveX controls, specifically designed to view and/or edit data, have been added. These include:

Data Binding Capabilities Added to Existing Controls

Intrinsic controls and many ActiveX Controls have new data properties associated with them now, in addition to the DataSource and DataField properties that have always existed. These are the four properties of interest:

The first three properties narrow in scope, from the DataSource down to the DataField, qualifying the source of the data. However, for complex data consumers such as the DataGrid, the DataField and DataFormat properties aren’t required, as the control handles them for you. For more information about the difference between simple-bound and complex-bound controls, see Creating Data-Aware Classes.

The controls which can be data bound using some or all of these properties include:

Additionally, the new Extender object also includes the DataSource, DataMember, and DataField properties. The Extender object is used to program controls added dynamically to your forms. For more information on the Extender and adding controls at run time, see Add Method (Controls Collection) and Extender Object.

Validation Enhancements

Data validation is now easier using the Validate event with the CausesValidation property. Using the two new features in tandem, you can prevent a control from losing focus until the information it contains has been validated. For more information about these features, see Validating Control Data by Restricting Focus.