public static bool SetCustomErrorProvidertoControl(ref ErrorProvider ep, ref Spectrum.Controls.TextBox txtBox, string errorMessage = "", bool flag = false) { try { if (flag == false) { if (errorMessage != "") { ep.SetError(txtBox, errorMessage); txtBox.BorderColor = System.Drawing.Color.Red; } else { ep.Clear(); txtBox.BorderColor = System.Drawing.Color.LightGray; return(true); } return(false); } return(false); } catch (Exception) { throw; } }
public static bool SetErrorProvidertoControl(ref ErrorProvider ep, ref Spectrum.Controls.TextBox textBox, string errorMessage = "", bool validateFormat = false) { try { if (!string.IsNullOrEmpty(textBox.Value.ToString()) && validateFormat) { ep.SetError(textBox, errorMessage); ep.SetIconAlignment(textBox, ErrorIconAlignment.MiddleRight); ep.SetIconPadding(textBox, 2); ep.BlinkRate = 1000; ep.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; textBox.BorderColor = System.Drawing.Color.Red; return(false); } else if (string.IsNullOrEmpty(textBox.Value.ToString())) { ep.SetError(textBox, errorMessage); ep.SetIconAlignment(textBox, ErrorIconAlignment.MiddleRight); ep.SetIconPadding(textBox, 2); ep.BlinkRate = 1000; ep.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; textBox.BorderColor = System.Drawing.Color.Red; return(false); } else { ep.SetError(textBox, string.Empty); textBox.BorderColor = DefaultBorderColor; return(true); } return(false); } catch (Exception) { throw; } }