|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
ErrorProvider Component Overview (Windows Forms)
The Windows Forms ErrorProvider component is used to validate user input on a form or control. It is typically used in conjunction with validating user input on a form, or displaying errors within a dataset. An error provider is a better alternative than displaying an error message in a message box, because once a message box is dismissed, the error message is no longer visible. The component displays an error icon () next to the relevant control, such as a text box; when the user positions the mouse pointer over the error icon, a ToolTip appears, showing the error message string.
The ErrorProvider component's key properties are, , and . When using ErrorProvider component with data-bound controls, the ContainerControl property must be set to the appropriate container (usually the Windows Form) in order for the component to display an error icon on the form. When the component is added in the designer, the ContainerControl property is set to the containing form; if you add the control in code, you must set it yourself.
The Icon property can be set to a custom error icon instead of the default. When the DataSource property is set, the ErrorProvider component can display error messages for a dataset. The key method of the ErrorProvider component is themethod, which specifies the error message string and where the error icon should appear.
The ErrorProvider component does not provide built-in support for accessibility clients. To make your application accessible when using this component, you must provide an additional, accessible feedback mechanism.