Show: Delphi C++
Display Preferences

Working with Field Component Methods at Runtime

From RAD Studio
Jump to: navigation, search

Go Up to Working with Field Components Index


Field components methods available at run time enable you to convert field values from one data type to another, and enable you to set focus to the first data-aware control in a form that is associated with a field component.

Controlling the focus of data-aware components associated with a field is important when your application performs record-oriented data validation in a dataset event handler (such as Data.DB.TDataSet.BeforePost). Validation may be performed on the fields in a record whether or not its associated data-aware control has focus. Should validation fail for a particular field in the record, you want the data-aware control containing the faulty data to have focus so that the user can enter corrections.

You control focus for a field data-aware components with a field FocusControl method. FocusControl sets focus to the first data-aware control in a form that is associated with a field. An event handler should call a field FocusControl method before validating the field. The following code illustrates how to call the FocusControl method for the Company field in the Customers table:

 CustomersCompany.FocusControl;
 CustomersCompany->FocusControl();

The following table lists some other field component methods and their uses. For a complete list and detailed information about using each method, see Data.DB.TField.

Selected field component methods:

Method Purpose

AssignValue

Sets a field value to a specified value using an automatic conversion function based on the field type.

Clear

Clears the field and sets its value to NULL.

GetData

Retrieves unformatted data from the field.

IsValidChar

Determines if a character entered by a user in a data-aware control to set a value is allowed for this field.

SetData

Assigns unformatted data to this field.



See Also

Personal tools
In other languages
Previous Versions
Assistance