AdvancedErrorProvider Class
An
ErrorProvider with a
SetMessage event, which is triggered if the
DataSource property is set and the message
of a bound property is about to be retrieved. It also fixes the scaling of the displayed icon if the
Icon property is explicitly set.
Namespace: KGySoft.WinForms.ComponentsAssembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
[ToolboxBitmapAttribute(typeof(ErrorProvider))]
public class AdvancedErrorProvider : ErrorProvider
<ToolboxBitmapAttribute(GetType(ErrorProvider))>
Public Class AdvancedErrorProvider
Inherits ErrorProvider
[ToolboxBitmapAttribute(typeof(ErrorProvider))]
public ref class AdvancedErrorProvider : public ErrorProvider
[<ToolboxBitmapAttribute(typeof(ErrorProvider))>]
type AdvancedErrorProvider =
class
inherit ErrorProvider
end
- Inheritance
- Object MarshalByRefObject Component ErrorProvider AdvancedErrorProvider
If the original ErrorProvider is used with WinForms data binding (by setting the DataSource property), the bound items
must implement the IDataErrorInfo interface to make the error messages appear on the controls.
The AdvancedErrorProvider class allows customizing this behavior by providing a SetMessage event, which can be handled
to allow the messages to be retrieved from any custom source.
If the bound objects implement the IDataErrorInfo interface, the error messages are preinitialized in
the SetMessageEventArgs.Message property when the SetMessage event is raised.
To provide error/message/info messages for objects, create three instances of this class. Set their icon accordingly (you can use the
properties of the Icons class from KGySoft.Drawing),
and handle the SetMessage event. You can derive the bound objects from the ValidatingObjectBase class
(or implement the IValidatingObject interface)
to provide error/warning/info messages for the bound properties. See also the Examples section for an illustration.
If you explicitly set the Icon property, and the IconSizeMode property is not SystemDefault,
the AdvancedErrorProvider component ensures that the icon is scaled correctly on all platform targets.
See the Remarks section of the IconSizeMode property for more details.
The following image illustrates how to use three AdvancedErrorProvider instances to provide error, warning and info messages for controls
by using data binding, and deriving the items from the ValidatingObjectBase class:

The image above is from the
example application,
where you can find the source code of
At the
Releases page of the project repository you can download it as executable binaries as well.
The example is located under the
Misc Tests /
AdvancedErrorProvider example menu.
| ContainerControl | Gets or sets a value indicating the parent control for this ErrorProvider. |
| Icon |
Gets or sets the icon for this AdvancedErrorProvider.
Explicitly set icons can be scaled automatically, depending on the IconSizeMode property.
See the Remarks section of the IconSizeMode property for details.
|
| IconSizeMode |
Gets or sets the icon sizing behavior for explicitly set icons.
Default value: AutoScale.
|
| ShowBindingErrors |
Gets or sets whether binding errors should be shown by this AdvancedErrorProvider.
Default value: .
|
| SetMessage |
Occurs when the DataSource property is set and the message of a bound property is about to be retrieved.
|