• As mentioned earlier, there are three custom data aware tools, in addition
to the standard Visual Basic tools: the DataList, DataCombo, and DataGrid ADO
tools. We’ll present each of these, giving their suggested use, some properties
and some events. If the icons for these tools are not in the toolbox, select Project
from the main menu, then click Components. Select Microsoft DataList Controls
6.0 (OLEDB) and Microsoft DataGrid 6.0 (OLEDB) in the Components window. Click
OK - the controls will appear.
• Like the data control, previous
versions of Visual Basic used DAO versions of the list, combo, and grid controls,
named DBList, DBCombo, and DBGrid. Make sure you are not using these tools.
• DataList Box:
The first bound data custom tool is the DataList Box. The list box is automatically
filled with a field from a specified data control. Selections from the list box
can then be used to update another field from the same data control or, optionally,
used to update a field from another data control.
Some properties of the DataList box are:
DataSource - Name of data control that is updated by the selection.
DataField - Name of field updated in Recordset specified by
RowSource - Name of data control used as source of items in
ListField - Name of field in Recordset specified by RowSource
used to fill list box.
BoundColumn - Name of field in Recordset specified by RowSource
to be passed to DataField, once selection is made. This is usually the same as
BoundText - Text value of BoundColumn field. This is the value
passed to DataField property.
Text - Text value of selected item in list. Usually the same
The most prevalent use of the DataList box is to fill the list from the database,
then allow selections. The selection can be used to fill any tool on a form, whether
it is data aware or not.
As a quick example, here is a DataList box filled with the Title (ListField)
field from the dtaExample (RowSource) data control. The data control is bound
to the Titles table in the BIBLIO.MDB database.
• DataCombo Box:
The DataCombo Box is nearly identical to the DataList box, hence we won’t
look at a separate set of properties. The only differences between the two tools
is that, with the DataCombo box, the list portion appears as a drop-down box and
the user is given the opportunity to change the contents of the returned Text
• DataGrid Tool:
The DataGrid tool is, by far, the most useful of the custom
data bound tools. It can display an entire database table, referenced by a data
control. The table can then be edited as desired.
The DataGrid control is in a class by itself, when considering
its capabilities. It is essentially a separate, highly functional program. The
only property we’ll be concerned with is the DataSource
property, which, as always, identifies the table associated with the respective
data control. Refer to the Visual Basic Programmer’s Guide and other references
for complete details on using the DataGrid control.
As an example of the power of the DataGrid control, here’s
what is obtained by simply setting the DataSource property to
the dtaExample data control, which is bound to the Titles table in the BIBLIO.MDB
At this point, we can scroll through the table and edit any values we choose.
Any changes are automatically reflected in the underlying database. Column widths
can be changed at run-time! Multiple row and column selections are possible! Like
we said, a very powerful tool.