Field components methods available at runtime 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 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's data-aware components with a field's 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's 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 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's 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. |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|