LMD-Tools Validators Guide


Error Providers


Overview

 

Error Providers are components which support various ways of indicating to user errors detected by Validators, e.g. TLMDIconErrorProvider  displays a user-defined icon near the validated control, TLMDControlErrorProvider displays a validation message in the referenced control which supports ILMDValidationMsgControl interface etc.

 

All the Error Providers are descendants of the TLMDCustomErrorProvider class. This abstract class introduces several properties and methods common for all the Error Providers components which control indication of errors. These key properties and methods are described below.

 

There's a set of Error Provider components available in the LMD Validators Pack which introduce properties specific to their ways of error feedback. These properties are described below in the Available Error Providers table.

 

Common Key Properties

 

Name

Type

Description

Active

Boolean

If Active is set to False, the Error Provider component does not perform any error  indication and its DisplayError does nothing. If Active is set to True (default), the call to DisplayError function performs actual validation.

MinErrorLevel

TLMDErrorLevel = Integer

MinErrorLevel defines the lower limit of the range of Error levels of validation errors (returned by Validators) which are handled by the Error Provider. Errors with error levels less then MinErrorLevel are ignored. This allows for specifying different ways of error indication (e.g. label controls with different font color, different icons) for different errors.

MaxErrorLevel

TLMDErrorLevel = Integer

MaxErrorLevel defines the upper limit of the range of Error levels of validation errors (returned by Validators) which are handled by the Error Provider. Errors with error levels greater then MinErrorLevel are ignored. This allows for specifying different ways of error indication (e.g. label controls with different font color, different icons) for different errors.

 

Common Key Methods

 

Name

Parameters

Result type

Description

DisplayError

control: ILMDValidatedControl; ErrorMsg: String;

ErrorLevel: TLMDErrorLevel

none

If ErrorLevel is non-zero, displays error in the way supported by Error Provider (e.g. shows an icon, displays a hint message etc.); otherwise stops error indication if it makes sense (e.g. hides an icon, removes a hint message etc.). Control parameter is a reference to a control for which the error is to be indicated. ErrorMsg parameter is an error message used for error indication (e.g. hint text, text displayed in a devoted control etc).

 

Available Error Providers

 

Name

Description

TLMDInPlaceErrorProvider

Modifies the appearance of the validated control: by default changes background and font color, or lets the control itself perform any modifications if it doesn't support default way of in-place indication (see ILMDValidatedControl interface description for details). Key properties are IndicationFontColor (the color of the control's font used for error indication; when error indication is over, the font color is restored to the initial value) and IndicationBackColor (the color of the control's background used for error indication; when error indication is over, the background color is restored to the initial value)

TLMDIconErrorProvider

Displays a user-defined icon near the validated control. The key properties are: ErrorIcon of type TBitmap - the icon to be displayed; ErrorIconPosition of type TAnchorKing (can be akLeft, akTop, akRight, akBottom) - specifies the position relative to the control where the icon is to be displayed; ErrorIconDistance of type Integer - the distance from the control in pixels where the icon is to be displayed.

TLMDHintErrorProvider

Displayes a hint message for the validated control. The key property is MessageHint - TLMDMessageHint object used to display a message which properties can be controlled to modify its appearance.

TLMDMessageBoxErrorProvider

Displayes a standard dialog box with the error message.

TLMDControlErrorProvider

Passes the error message to a devoted control which supports ILMDValidationMsgControl interface by calling its SetErrorMessage method. Several controls from LMD Tools Pack support this interface including TLMDSimpleLabel and other label components, TLMDListBox, TLMDStatusBar etc. Some controls from the LMD Demo VCL Controls Validation Pack also support this interface. See How to create a new error messaging control topic for details. The key property of the Error Provider is ErrMsgControl which is a reference to the control supporting ILMDValidationMsgControl interface.

TLMDErrorProvider

An integrated Error Provider component which aggregates TLMDInPlaceErrorProvider, TLMDIconErrorProvider, TLMDMessageBoxErrorProvider and TLMDControlErrorProvider. Can be used to indicate errors in several ways and is in this sense an alternative to using Error Provider Group component

 

See also

 

ILMDValidatedControl interface description, How to create a new error messaging control topic.