private void textBox1_Validated(object sender, System.EventArgs e) { if (myValidateTextBox1()) this.errorProvider1.SetError(this.textBox1,"Error textbox1"); else this.errorProvider1.SetError(this.textBox1,""); } private void textBox2_Validated(object sender, System.EventArgs e) { if (myValidateTextBox2()) this.errorProvider1.SetError(this.textBox2,"Error textbox2"); else this.errorProvider1.SetError(this.textBox2,""); } private void textBox3_Validated(object sender, System.EventArgs e) { if (myValidateTextBox3()) this.errorProvider1.SetError(this.textBox3,"Error textbox3"); else this.errorProvider1.SetError(this.textBox3,""); } private bool myValidateTextBox1() { // validation code return boolValue } private bool myValidateTextBox2() { // validation code return boolValue } private bool myValidateTextBox3() { // validation code return boolValue }This way you can call the following code in the save button click:
if (myValidateTextBox1()) { this.errorProvider1.SetError(this.textBox1,"Error textbox1"); return; } if (myValidateTextBox2()) { this.errorProvider1.SetError(this.textBox2,"Error textbox2"); return; } if (myValidateTextBox3()) { this.errorProvider1.SetError(this.textBox3,"Error textbox2"); return; } MessageBox.Show("There were no errors and save can continue!");I don't know if this is the best way of accomplishing this, but it is atleast one way of doing it.
>CancelEventArgs ce = new CancelEventArgs(false); >this.txtDetails.Invoke(new MyDelegate(this.txtDetails_Validating),new object[]{this.txtDetails,ce}); >>