Error Providers

Navigation:  Components >

Error Providers

Previous pageReturn to chapter overviewNext page

Overview

 

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

 

All error providers are descendants of the TNGCustomErrorProvider 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 NG ValidatorsPack 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

TNGErrorLevel = 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

TNGErrorLevel = 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: INGValidatedControl; ErrorMsg: String;

ErrorLevel: TNGErrorLevel

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

TNGInPlaceErrorProvider

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 INGValidatedControl 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)

TNGIconErrorProvider

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

TNGHintErrorProvider

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

TNGMessageBoxErrorProvider

Displayes a standard dialog box with the error message.

TNGControlErrorProvider

Passes the error message to a devoted control which supports INGValidationMsgControl interface by calling its SetErrorMessage method. Several NG ValidatorsPack controls support this interface including TNGSimpleLabel and other label components, TNGListBox, TNGStatusBar etc. Some controls from the example validation aware controls also support this interface. See How to Create a New Error Messaging Control topic for details. The key property of the error provider is Control which is a reference to the control supporting INGValidationMsgControl interface.

TNGErrorProvider

An integrated Error Provider component which aggregates TNGInPlaceErrorProvider, TNGIconErrorProvider, TNGMessageBoxErrorProvider and TNGControlErrorProvider. Can be used to indicate errors in several ways and is in this sense an alternative to using Error Provider Group component

 

See also

 

INGValidatedControl interface description, How to Create a New Error Messaging Control topic.