public static int GetErrorCount(this ErrorProvider ep) { var controls = ep.GetOrSetAttached(() => new HashSet <Control>()).Value; var errControls = from c in controls let err = ep.GetError(c) let hasErr = !string.IsNullOrEmpty(err) where hasErr select c; var errCount = errControls.Count(); return(errCount); }
public static void TrackControl(this ErrorProvider ep, Control c) { var controls = ep.GetOrSetAttached(() => new HashSet <Control>()).Value; controls.Add(c); }