Create a New Validated Control

Navigation:  How To... >

Create a New Validated Control

Previous pageReturn to chapter overviewNext page

A validated control is any control which supports INGValidatedControl interface. Following are some notes on adding INGValidatedControl interface support to a control:

 

1.The control should maintain a reference (of type TNGValidationEntity) to the validator assigned to its Validator property (e.g. FValidator); Notification procedure should be overridden to handle referenced validator component destruction (see Borland documentation for details);

2.The control should call the Validate function of FValidator after any change of the value contained in this control, as a rule passing Self as Sender parameter; typically Change method should be overridden for this purpose;

3.If the control should respond to in-place error indication in the default way, as performed by TNGInPlaceErrorProvider (font and background colors are changed to specified values),SupportsDefaultIndication function should return True and ControlBackBrush and ControlFont properties should provide a non-nil meaningful values (typically values of control's Font and Brush properties). If some special in-place indication is desired, SupportsDefaultIndication function should return False, and RespondToError procedure should perform some actions to modify control's look correspondingly to the passed value of ErrorLevel.

4.GetValueToValidate function should return a value which is to be validated (entered/seen by a user); often it is the value of the control's Text property;

5.Control property should in most cases refer to control's Self (for specific controls which aggregate other controls it can refer to one of the aggregated controls).

 

See provided with the package example validation aware controls for examples of implementing validated controls.