Enabling Simple Data Binding with the Type Library

From RAD Studio
Jump to: navigation, search

Go Up to Customizing the ActiveX Control's Interface


With simple data binding, you can bind a property of your ActiveX control to a field in a database. To do this, the ActiveX control must communicate with its host application about what value represents field data and when it changes. You enable this communication by setting the property's binding flags using the Type Library editor.

By marking a property bindable, when a user modifies the property (such as a field in a database), the control notifies its container (the client host application) that the value has changed and requests that the database record be updated. The container interacts with the database and then notifies the control whether it succeeded or failed to update the record.

Note: The container application that hosts your ActiveX control is responsible for connecting the data-aware properties you enable in the type library to the database.

Use the type library to enable simple data binding:

  1. On the toolbar, click the property that you want to bind.
  2. Choose the flags page.
  3. Select the following binding attributes:
Binding attribute Description

Bindable

Indicates that the property supports data binding. If marked bindable, the property notifies its container when the property value has changed.

Request Edit

Indicates that the property supports the OnRequestEdit notification. This allows the control to ask the container if its value can be edited by the user.

Display Bindable

Indicates that the container can show users that this property is bindable.

Default Bindable

Indicates the single, bindable property that best represents the object. Properties that have the default bind attribute must also have the bindable attribute. Cannot be specified on more than one property in a dispinterface.

Immediate Bindable

Allows individual bindable properties on a form to specify this behavior. When this bit is set, all changes will be notified. The bindable and request edit attribute bits need to be set for this new bit to have an effect.

  1. Click the Refresh button on the toolbar to update the type library.To test a data-binding control, you must register it first. For example, to convert a TEdit control into a data-bound ActiveX control, create the ActiveX control from a TEdit and then change the Text property flags to Bindable, Display Bindable, Default Bindable, and Immediate Bindable. After the control is registered and imported, it can be used to display data.

See Also