ErrorProvider Component¶
In a ScriptoForm, an ErrorProvider component provides a user interface for indicating that a control on a form has an error associated with it or to notify the user of a data entry error. This normally manifests itself in the form of a red "X" icon in the vicinity of the control in a error state that includes a tooltip that provides a customizable error message. A single ErrorProvider component can be used with multiple controls on a form.
Examples¶
# Create the ErrorProvider:
$ErrorProviderMain = New-Object -TypeName System.Windows.Forms.ErrorProvider
# Display error icon with custom error message if invalid data detected:
$ErrorProviderMain.SetIconPadding($TextBoxName,-20)
$ErrorProviderMain.SetError($TextBoxName,"ErrorĀ message.")
# Clear error icon if valid data detected:
$ErrorProviderMain.Clear()
Notes¶
The above example shows how to display the error icon within the control text region instead of outside of it by using a negative parameter value in the SetIconPadding method.
References¶
ErrorProvider Class (System.Windows.Forms) | Microsoft Learn