Skip to main content

TcxCustomEditProperties.ValidationOptions Property

Contains a set of flags that specify how the editor handles and displays its validation errors.

Declaration

property ValidationOptions: TcxEditValidationOptions read; write; default [evoRaiseException];

Property Value

Type
TcxEditValidationOptions

Remarks

You can set any combination of the following flags for the ValidationOptions property.

Flag

Description

evoRaiseException

If set, an exception is raised to display the error message if validation fails. In addition, the error message is displayed in a hint window when an end-user hovers the mouse pointer over an error icon (see the evoShowErrorIcon flag description below).

To enable raising exceptions in spin editors, make certain that in addition to the evoRaiseException flag, the editor Properties.ExceptionOnInvalidInput property is set to True.

evoShowErrorIcon

If set, the editor displays an error icon if validation fails. Hovering the mouse pointer over this icon displays a hint window with the error message. Below are the details on how you can customize the default error indication.

General Information

The error icon to be displayed is determined by the ErrorType and ErrorIcon properties of a TcxEditValidateInfo object included as part of the editor ViewInfo. Normally, the error icon is not displayed because these properties are initialized with the values that correspond to a valid edit value – they are set to eetNone and nil, respectively. The method with which you can modify these properties depends on the editor version in use (standalone or in-place). In any case, you can specify how the error icon is horizontally aligned within the editor using the editor Properties.ValidationErrorIconAlignment property.

Standalone Editor Validation

If a standalone editor fails validation, the TcxEditValidateInfo.ErrorType property is set to eetError and the TcxEditValidateInfo.ErrorIcon property is initialized with the default error icon that corresponds to eetError. If you provided a custom error icon via the editor Properties.ErrorIcon property, then the TcxEditValidateInfo.ErrorIcon property will be initialized with this icon instead. To dynamically specify an error icon, assign the Properties.ErrorIcon property in an editor Properties.OnValidate event handler.

After that, the standalone editor displays the error icon next to its input field.

Rather than providing a custom error icon, you can use any of the default error icons (Error, Warning, or Information) that are shipped with the ExpressEditors Library. These icons are stored by the cxEditErrorIcon, cxEditWarningIcon, and cxEditInfoIcon global variables. So, you can assign any of them to the editor Properties.ErrorIcon property to have the corresponding error icon displayed by the editor.

In-place Editor Validation

You can visualize validation errors in any cell associated with an in-place editor in the ExpressQuantumGrid, ExpressQuantumTreeList, or ExpressVerticalGrid control. To accomplish this, handle the OnValidateDrawValue event of a specific column/row, access the cell editor TcxEditValidateInfo object via the AData event parameter, and customize object properties as required. Handle this event in combination with the column/row Properties.OnValidate event to utilize the same validation logic when editing and displaying cell values.

As with the standalone editor validation, you can assign any of the default error icons stored by the cxEditErrorIcon, cxEditWarningIcon, and cxEditInfoIcon global variables to the TcxEditValidateInfo.ErrorIcon property. However, it’s much easier to set the TcxEditValidateInfo.ErrorType property to the corresponding value and assign nil to TcxEditValidateInfo.ErrorIcon.

evoAllowLoseFocus

If set, an end-user can move focus from the editor if it fails validation. Otherwise, focus cannot be moved to any other control unless validation succeeds.

Note that evoRaiseException has a higher priority than evoAllowLoseFocus – if both these flags are set and an exception is raised, the editor retains its focus.

Use the following demos to learn how to tailor the ValidationOptions property, the OnValidateDrawValue and Properties.OnValidate events for editor validation:

  • For standalone editors, see the EditorsValidationDemo shipped with the ExpressEditors Library;

  • For in-place editors, see the EditorsInPlaceValidationDemo shipped with the ExpressQuantumGrid, ExpressQuantumTreeList, and ExpressVerticalGrid Suites.

The default value of the ValidationOptions property is [evoRaiseException].

See Also