All the error which occures on design time are be collected in the FormErrorCollection
To get all the design time error like validation, schema error the write bellow code
FormErrorCollection MyError = this.Errors;
This MyError will have all the error which occured in the form.
MyError have all the details of error of all the control. Loop into this and get all the detials.
foreach (FormError AllError in MyError)
{
//write message box code
}
Then show the details in the message box or any other control in the form
string errorMessage = string.Empty;
//write message box code
errorMessage = errorMessage + AllError.Site.LocalName + " : " + AllError.Message + System.Environment.NewLine;
and message box
if (MyError.Count != 0)
{
MessageBox.Show(errorMessage);
}
Full Code :
FormErrorCollection MyError = this.Errors;
string errorMessage = string.Empty;
foreach (FormError AllError in MyError)
{
errorMessage = errorMessage + AllError.Site.LocalName + " : " + AllError.Message + System.Environment.NewLine;
}
if (MyError.Count != 0)
{
MessageBox.Show(errorMessage);
}
No comments:
Post a Comment