Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Note that Visual Basic also supports some additional data-bound controls to work with the ADO data control specifically, and those controls are covered in the following topic.

Let’s see an example. In the program in Figure 24.19, we’ve added a number of controls that we bind to a data control, Data1. The data control, in turn, is connected to the db.mdb database we created in the beginning of the chapter. When you move through the database with the data control, the data in each bound control is updated. The code for this example is located in the dbcontrols folder on this book’s accompanying CD-ROM.


Figure 24.19  An example program showing the use of bound controls.

The ADO Data-Bound Controls

There are three data-bound controls that are specially optimized for use with the ADO data control: DataGrid controls, DataCombo controls, and DataList controls (don’t confuse these controls with the non-ADO optimized data-bound controls like the DBCombo and DBList controls). These controls are specifically designed to work with ADO data controls and won’t work with standard controls like the data control.

To add these controls to a program, follow these steps:

1.  Select the Project|Components menu item.
2.  Click the Controls tab in the Components dialog box that opens.
3.  Select both the Microsoft DataGrid Control entry and the Microsoft DataList Controls entry in the Controls list box.
4.  Click on OK to close the Components dialog box.
5.  This adds the DataGrid, DataCombo, and DataList control tools to the toolbox; draw those controls as you want them on your form.

Here are the principal data properties you use with these three controls:

  DataGridDataSource = ADO data control’s name. You can also set the AllowAddNew, AllowDelete, AllowUpdate properties to True or False to enable or disable those operations.
  DataComboDataSource = ADO data control’s name; DataField = Name of the field to display in the combo’s text box; ListField = Name of field to display in the list; RowSource = ADO data control’s name; and BoundColumn = Name of the source field with which you can provide data to another control.
  DataListDataSource = ADO data control’s name; DataField = Name of the field to display in the current selection, ListField = Name of field to display in the list, RowSource = ADO data control’s name, BoundColumn = Name of the source field with which you can provide data to another control.

Let’s see an example. In this case, we’ve added an ADO data control and the three ADO data-bound controls to a program, as shown in Figure 24.20, and connected them to the ADO data control using their various properties. That’s all it takes, and we’re in business. The code for this example is located in the dbcontrols2 folder on this book’s accompanying CD-ROM.


Figure 24.20  Using the ADO bound controls.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.