Handling Events

From RAD Studio
Jump to: navigation, search

Go Up to Setting Persistent Field Properties and Events

Like most components, field components have events associated with them. Methods can be assigned as handlers for these events. By writing these handlers you can react to the occurrence of events that affect data entered in fields through data-aware controls and perform actions of your own design. The following table lists the events associated with field components:

Field component events :

Event Purpose


Called when the value for a field changes.


Called when the value for a field component is retrieved for display or editing.


Called when the value for a field component is set.


Called to validate the value for a field component whenever the value is changed because of an edit or insert operation.

Data.DB.TField.OnGetText and Data.DB.TField.OnSetText events are primarily useful to programmers who want to do custom formatting that goes beyond the built-in formatting functions. OnChange is useful for performing application-specific tasks associated with data change, such as enabling or disabling menus or visual controls. Data.DB.TField.OnValidate is useful when you want to control data-entry validation in your application before returning values to a database server.

To write an event handler for a field component

  1. Select the component.
  2. Select the Events page in the Object Inspector.
  3. Double-click the Value field for the event handler to display its source code window.
  4. Create or edit the handler code.

See Also