G
Guest
Hi there
I am trying to implement very simple field data validation:
I have a form with one TextBox (textBox1) on it. To validate user input I implemented Validating event handler (usual stuff)
private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
string error = null;
if (textBox1.Text == String.Empty)
{
e.Cancel = true;
error = "need text here";
}
errorProvider.SetError((Control)sender, error);
}
My problem is that when I click on form’s control box close button I don’t want any validation to happen as I’m going to close the form.
If I had my own “Close†button on this form I could set it’s CausesValidaton property to false and the problem would be solved.
Are there any properties of the form that I can set to avoid validation? Any suggestions?
Thanx
I am trying to implement very simple field data validation:
I have a form with one TextBox (textBox1) on it. To validate user input I implemented Validating event handler (usual stuff)
private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
string error = null;
if (textBox1.Text == String.Empty)
{
e.Cancel = true;
error = "need text here";
}
errorProvider.SetError((Control)sender, error);
}
My problem is that when I click on form’s control box close button I don’t want any validation to happen as I’m going to close the form.
If I had my own “Close†button on this form I could set it’s CausesValidaton property to false and the problem would be solved.
Are there any properties of the form that I can set to avoid validation? Any suggestions?
Thanx