Binding Collection Object VB Description

The BindingCollection object—as the name suggests—is a collection of Binding objects. The BindingCollection object plays a central role in the new data-binding technology in VB6, allowing you to automatically map data fields to standard form controls and to specify formatting for those data. Your application can have any number of BindingCollection objects, each referring to a distinct data member provided by a data source such as an ADO recordset or a VB data source class. The Binding objects held within the class represent the individual mapping of consumer control property to data provider field, a relationship created using the BindingCollections Add method.

The relationship between the various data binding elements is shown in Figure 7-1.

For an overview of data-binding objects, including the library reference needed to access the object model, see the Data Binding Objects entry.


BindingCollection Properties


Data Type: Long

The number of Binding objects in the collection.

134 Chapter 7- The Language Reference

Data Consumer Control Property

DataMember Data Field -

-*■ Binding Object -»- Binding Object

Data Consumer Control

Data Field Data Field Data Field -


Binding Object -*■ Binding Object

Property Data Consumer Control

DataMember Data Field " Data Field "

Binding Object

Data Consumer Control Property

Data Field " Data Field *

n h

-*■ Binding Object -»■ Binding Object

Property Data Consumer Control

-*■ Binding Object



Data Consumer Control Property

Figure 7-1: How data-binding elements relate to each other

Figure 7-1: How data-binding elements relate to each other


Type: DataMember

An optional string specifying the data member to use from the data source. This is useful where the source provides more than one data member. A DataSource application can provide many data members; you need to create a BindingCollection object for each data member to which you wish to bind.


Data Type: DataSource

A valid data source object such as an ADO recordset or a VB class object set to vbDataSource. The DataSource is distinct from the DataMember; the DataSource is the application providing the data, whereas the Data-Member is a discrete recordset within the DataSource.


Data Type: Binding Object

Returns a Binding object. If you use a key string in the Add method, you can also access the Binding object by key, as in:



Type: UpdateMode enumerated constant (see below)

Specifies at what stage the data source is updated. However, if you open a recordset as read-only, no update occurs.

BindingCollection Object (VB6) 135

UpdateMode Constants vbUpdateWhenPropertyChanges Value: 1

Don't use this constant when dealing with VB class data sources. I found it disabled the Binding object's DataChanged property.

vbUpdateWhenRowChanges Value: 2

The recordset is updated.

vbUsePropertyAttributes Value: 0

Not relevant to class data sources.

BindingCollection Methods

The BindingCollection object supports the Add. Clear, and Remove collection object methods. For details, see the entries for each method.

Was this article helpful?

0 0

Post a comment