Validation using Validating event and ErrorProvider – Show Error Summary

You should first correct your validating events this way: private void textBox1_Validating(object sender, CancelEventArgs e) { Regex regex1 = new Regex(@”^[a-zA-Z]+$”); if (!regex1.IsMatch(textBox1.Text)) { //To set validation error errorProvider1.SetError(textBox1, “Nosaukums nedrīskt saturēt ciparus!”); //To say the state of control in invalid e.Cancel = true; } else { //To clear the validation error this.errorProvider1.SetError(this.textBox1, “”); } … Read more

C# WinForms ErrorProvider Control

This falls in the category of “how can you not know”. It is your code that is calling ErrorProvider.SetError(), you should have no trouble keeping track of how many errors are still active. Here’s a little helper class, use its SetError() method to update the ErrorProvider. Its Count property returns the number of active errors: … Read more