Responding to Data Changes

From RAD Studio
Jump to: navigation, search

Go Up to Creating a Data Browsing Control

Once a control has a data link and properties to specify the data source and data field, it needs to respond to changes in the data in that field, either because of a move to a different record or because of a change made to that field.

Data link classes all have events named OnDataChange. When the data source indicates a change in its data, the data link object calls any event handler attached to its OnDataChange event.

To update a control in response to data changes, attach a handler to the data link's OnDataChange event.

In this case, you will add a method to the calendar, then designate it as the handler for the data link's OnDataChange.

Declare and implement the DataChange method, then assign it to the data link's OnDataChange event in the constructor. In the destructor, detach the OnDataChange handler before destroying the object.