RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TField.OnValidate Event

Occurs just before the data is written to the record buffer.

Pascal
property OnValidate: TFieldNotifyEvent;
C++
__property TFieldNotifyEvent OnValidate;

Write an OnValidate event handler to validate changes made to the data in the field, just before the data is written to the current record buffer. The EditMask property allows validation of the data on a character by character basis while it is being entered by the user. OnValidate allows an application to validate the data as a whole.  

When the value of a field component is assigned programmatically, validation by the EditMask is bypassed, since there is no data-aware control to enforce adherence to the mask. OnValidate allows an application to validate such data before it is posted to the database table. 

To reject the current value of the field from the OnValidate event handler, raise an exception. 

When writing the value of a field to the current record buffer, the following steps occur: 

1The OnValidate event handler is called to validate the data.  

2If the OnValidate event handler does not raise an exception, the data is written to the current record buffer.  

3If writing the data does not raise an exception, the OnChange event handler is called to allow a response to the change. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!