

#ERRORPROVIDER VB.NET ICON PLACEMENT WINDOWS#
Windows Forms supports ErrorProvider help on controls for data input validation. When the error icon is displayed, point at it with the mouse pointer to see the error text. This topic gives some information about ErrorProvider and Visual Basic. Type invalid (in this example, non-numeric) data into the first control, and then tab to the second.

System::ComponentModel::CancelEventHandler
#ERRORPROVIDER VB.NET ICON PLACEMENT CODE#
(Visual C#, Visual C++) Place the following code in the form's constructor to register the event handler. System::ComponentModel::CancelEventArgs ^ e)ĮrrorProvider1->SetError(textBox1, "Not an integer value.") Microsoft makes no warranties, express or implied, with respect to the information provided here.

System::Void textBox1_Validating(System::Object ^ sender, Important Some information relates to prerelease product that may be substantially modified before it’s released. Protected void textBox1_Validating (object sender,ĮrrorProvider1.SetError(textBox1, "Not an integer value.") Private Sub TextBox1_Validating(ByVal Sender As Object, _īyVal e As ) Handles _ĮrrorProvider1.SetError(TextBox1, "Not a numeric value.") The second argument is the error text to display. The first argument of the SetError method specifies which control to display the icon next to. The following code tests the validity of the data the user has entered if the data is invalid, the SetError method is called. Private Sub Form1Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ErrorProvider1. Now double click on the form and write this code. For more information, see How to: Create Event Handlers at Run Time for Windows Forms. Working with errorprovider: Drag a errorprovider, TextBox and a Button from the Toolbox. In order for this code to run properly, the procedure must be connected to the event. Select the first control and add code to its Validating event handler. To display an error icon when a control's value is invalidĪdd two controls - for example, text boxes - to a Windows Form.Īdd an ErrorProvider component to the form. You must have at least two controls on the form in order to tab between them and thereby invoke the validation code. You can use a Windows Forms ErrorProvider component to display an error icon when the user enters invalid data.
