ErrorProvider Control:
This article will explain the use of the error provider control in Win Forms application development.The error provider control is most useful to display errors associated with data entry tasks on a Windows form. The error provider control is typically used to show errors related to data entry.For example, successful entries could be shown with a green checkmark as easily as failed entries could be shown with the standard red ball exclamation mark. When user enters invalid value to the textbox then the errorprovider will be set or the user enters the currect value then errorprovider will be clear.You can use one errorprovider to display more error to different controls.
SetError method:
To set the error message to the control we have to use SetErro method. By default the errorProvider
will have red colored icon. That icon will represents for invalid data. If you want to set the valid symbol to the validated control, you can change the errorprovider icon which represents the valid information.
Event : This Code should write in textBox_Valitating event.
if (textBox1.Text == "")
{
errorProvider1.SetError(textBox1, "Textbox should not be empty.");
}
else {
errorProvider1.SetError(textBox1, "");
}
As this you can validate for textbox minimum length, maximum length and more for more validations.
I hope this code will help you.
This article will explain the use of the error provider control in Win Forms application development.The error provider control is most useful to display errors associated with data entry tasks on a Windows form. The error provider control is typically used to show errors related to data entry.For example, successful entries could be shown with a green checkmark as easily as failed entries could be shown with the standard red ball exclamation mark. When user enters invalid value to the textbox then the errorprovider will be set or the user enters the currect value then errorprovider will be clear.You can use one errorprovider to display more error to different controls.
SetError method:
To set the error message to the control we have to use SetErro method. By default the errorProvider
will have red colored icon. That icon will represents for invalid data. If you want to set the valid symbol to the validated control, you can change the errorprovider icon which represents the valid information.
Event : This Code should write in textBox_Valitating event.
if (textBox1.Text == "")
{
errorProvider1.SetError(textBox1, "Textbox should not be empty.");
}
else {
errorProvider1.SetError(textBox1, "");
}
As this you can validate for textbox minimum length, maximum length and more for more validations.
I hope this code will help you.
No comments:
Post a Comment