Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int errorCount;
- void SetError(Control c, string message)
- {
- if (message == "")
- errorCount--;
- else
- errorCount++;
- errorProvider.SetError(c, message);
- }
- bool IsValid()
- {
- foreach (Control c in errorProvider1.ContainerControl.Controls)
- if (errorProvider1.GetError(c) != "")
- return false;
- return true;
- }
- public static class ErrorProviderExtensions
- {
- private static int count;
- public static void SetErrorWithCount(this ErrorProvider ep, Control c, string message)
- {
- if (message == "")
- {
- if (ep.GetError(c) != "")
- count--;
- }
- else
- count++;
- ep.SetError(c, message);
- }
- public static bool HasErrors(this ErrorProvider ep)
- {
- return count != 0;
- }
- public static int GetErrorCount(this ErrorProvider ep)
- {
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement