/// <summary> /// Translate and set Message error on Error provider. /// </summary> /// <param name="idXML">Unique XML resource identifier.</param> /// <param name="defaultString">Default string returned if the resource is not found.</param> /// <param name="interactionToolkitAlias">Current alias of the interactiontoolkit layer.</param> protected virtual void SetMessageError(string idXML, string defaultString, string interactionToolKit) { string lMessageError = CultureManager.TranslateString(idXML, defaultString, interactionToolKit); mErrorProvider.SetError(this.mMaskedTextBoxIT, lMessageError); mErrorProvider.SetIconPadding(this.mMaskedTextBoxIT, -20); }
public void ErrorProvider_SetIconPadding_Invoke_GetIconPaddingReturnsExpected(int value) { var provider = new ErrorProvider(); var control = new Control(); provider.SetIconPadding(control, value); Assert.Equal(value, provider.GetIconPadding(control)); // Call again. provider.SetIconPadding(control, value); Assert.Equal(value, provider.GetIconPadding(control)); }
public MainForm () { // // _textBox // _textBox = new TextBox (); _textBox.Location = new Point (8, 8); _textBox.Size = new Size (210, 20); // // _errorProvider // _errorProvider = new ErrorProvider (); _errorProvider.SetIconAlignment (_textBox, ErrorIconAlignment.MiddleRight); _errorProvider.SetIconPadding (_textBox, 2); _errorProvider.ContainerControl = this; Controls.Add (_textBox); // // MainForm // ClientSize = new Size (240, 50); Location = new Point (280, 100); StartPosition = FormStartPosition.Manual; Text = "bug #329714"; Load += new EventHandler (MainForm_Load); }
public static void Set(Control control, string Info) { provider.SetError(control, Info); provider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); provider.SetIconPadding(control, 4); record.Add(control); }
public static void validatePrimaryEmail(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { string varRegex = @"^[A-Za-z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$"; Match match = Regex.Match(control.Text, @varRegex); eprWarning.SetIconPadding(control, 3); eprError.SetIconPadding(control, 3); //Run the validation if (validateEmptyField(control, eprWarning)) { // Here we check the regex match if (!match.Success) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Does not appear to be a valid email address"); } else { eprError.SetError(control, ""); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); } }
public static void validateTimezone(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { string varRegex = @"^UTC.\d{2}:\d{2}$"; Match match = Regex.Match(control.Text, @varRegex); eprWarning.SetIconPadding(control, 3); eprError.SetIconPadding(control, 3); //Run the validation if (validateEmptyField(control, eprWarning)) { // Here we check the regex match if (!match.Success) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Timezone not in expected format. i.e. UTC+01:00"); } else { eprError.SetError(control, ""); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); } }
//Validate individual form elements for blank values and regular expressions public static void validateGlideNumber(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { // This regEx only allows a single glide number, enforced disaster type and enforces upper case. //string varRegex = @"^((CW)|(CE)|(DR)|(EQ)|(EP)|(EC)|(ET)|(FA)|(FR)|(FF)|(FL)|(HT)|(IN)|(LS)|(MS)|(OT)|(ST)|(SL)|(AV)|(SS)|(AC)|(TO)|(TC)|(TS)|(VW)|(VO)|(WV)|(WF))-20\d{2}-\d{6}-[A-Z]{3}$"; // This regEx allow one or more comma seperated glide numbers, does not enforced disaster type and allows mixed case. string varRegex = @"^([a-zA-Z]{2}-20\d{2}-\d{6}-[a-zA-Z]{3})(, [a-zA-Z]{2}-20\d{2}-\d{6}-[a-zA-Z]{3})*$"; Match match = Regex.Match(control.Text, @varRegex); eprWarning.SetIconPadding(control, 3); eprError.SetIconPadding(control, 3); //Run the validation if (validateEmptyField(control, eprWarning)) { // Here we check the regex match if (!match.Success) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Glide number does not conform to standard. eg EQ-2013-123456-ABC"); } else { eprError.SetError(control, ""); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); } }
public bool Validate(string errorMessage) { bool lResult = true; //Checks combo value with values contained in list int lSearchItemInCombo = this.mComboBoxIT.FindStringExact(this.mComboBoxIT.Text); if ((this.mErrorProvider != null) && (this.mComboBoxIT != null)) { //Locate error message inside combo control mErrorProvider.SetIconPadding(this.mComboBoxIT, -35); // Null validation. if (!this.NullAllowed) { //Keep contained list validation message if (lSearchItemInCombo == -1 && !string.IsNullOrEmpty(this.mComboBoxIT.Text)) { return(false); } List <Oid> lOids = this.Value as List <Oid>; if ((lOids == null) || (lOids.Count == 0)) { mErrorProvider.SetError(this.mComboBoxIT, errorMessage); // Validation error. return(false); } } } // Validation OK. return(lResult); }
public static string validateMapSummary(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { string layoutMapSummary = string.Empty; Dictionary <string, string> dictMapValues = MapAction.PageLayoutProperties.getLayoutTextElements(_pMxDoc, targetMapFrame); if (dictMapValues.ContainsKey("summary")) { layoutMapSummary = dictMapValues["summary"]; } eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != layoutMapSummary && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Text differs from page layout 'summary' element value"); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.Dispose(); validateEmptyField(control, eprWarning); return("Blank"); } }
public static string validatePaperSize(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); string automatedValue = MapAction.PageLayoutProperties.getPageSize(_pMxDoc, targetMapFrame); if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != automatedValue && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Text differs from automated value"); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); return("Blank"); } }
public static string validateTime(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { Match match = Regex.Match(control.Text, @"\d\d:\d\d"); eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); //Run the validation if (validateEmptyField(control, eprWarning)) { // Here we check the regex match if (!match.Success) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Time doesn't comform to the format hh:mm"); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); return("Blank"); } }
public TimeTrackerProject() { InitializeComponent(); IsLoading = true; _projectName = new ErrorProvider(); _projectName.SetIconAlignment(textBox_project_name, ErrorIconAlignment.MiddleRight); _projectName.SetIconPadding(textBox_project_name, 2); _projectName.BlinkRate = 1000; _projectName.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; _dateDue = new ErrorProvider(); _dateDue.SetIconAlignment(dateTimePicker_due, ErrorIconAlignment.MiddleRight); _dateDue.SetIconPadding(dateTimePicker_due, 2); _dateDue.BlinkRate = 1000; _dateDue.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; _dateComplete = new ErrorProvider(); _dateComplete.SetIconAlignment(dateTimePicker_completed, ErrorIconAlignment.MiddleRight); _dateComplete.SetIconPadding(dateTimePicker_completed, 2); _dateComplete.BlinkRate = 1000; _dateComplete.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; }
public void SetError(string message, int padding = 0) { _errorProvider.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError; _errorProvider.SetError(SComponent, message); _errorProvider.SetIconAlignment(SComponent, ErrorIconAlignment.MiddleRight); _errorProvider.SetIconPadding(SComponent, padding == 0 ? -20 : padding); }
public void ShowHelp(Control control) { if (!this._panel1.Visible) { return; } string text = this._toolTip.GetToolTip(control); this._panel1.Text = text; if (_cancel != null) { _cancel.Cancel(); _hideErrorProvider.Wait(); } _errorProvider.Clear(); if (!string.IsNullOrEmpty(text)) { _errorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); _errorProvider.SetIconPadding(control, 4); _errorProvider.SetError(control, "This input is currently being described in the help side-bar"); _cancel = new CancellationTokenSource(); _hideErrorProvider = new Task(HideErrorProvider); _hideErrorProvider.Start(); } }
public static bool SetErrorProvidertoControlForWindowsForm(ref ErrorProvider ep, ref System.Windows.Forms.ComboBox comboBox, string errorMessage = "", bool validateFormat = false) { try { if (comboBox.SelectedIndex == -1 || comboBox.SelectedValue == null || comboBox.SelectedValue.ToString() == "Select") { ep.SetError(comboBox, errorMessage); ep.SetIconAlignment(comboBox, ErrorIconAlignment.MiddleRight); ep.SetIconPadding(comboBox, 2); ep.BlinkRate = 1000; ep.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; // comboBox.VisualStyle = C1.Win.C1List.VisualStyle.Office2007Silver; return(false); } else { ep.SetError(comboBox, string.Empty); //comboBox.VisualStyle = C1.Win.C1List.VisualStyle.Office2007Blue; return(true); } } catch (Exception ex) { throw ex; } }
private void SetAddressErrorProviderToTextBox(TextBox textBoxToAdd) { addressErrorProvider = new ErrorProvider(); addressErrorProvider.SetIconAlignment(textBoxToAdd, ErrorIconAlignment.MiddleRight); addressErrorProvider.SetIconPadding(textBoxToAdd, 2); addressErrorProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink; }
public Form1() { InitializeComponent(); chosenValuesErrorProvider = new ErrorProvider(); chosenValuesErrorProvider.SetIconAlignment(txtbPodajWartosci, ErrorIconAlignment.MiddleRight); chosenValuesErrorProvider.SetIconPadding(txtbPodajWartosci, 2); chosenValuesErrorProvider.BlinkRate = 500; chosenValuesErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; txtbPodajWartosci.TextChanged += new EventHandler(txtbPodajWartosci_TextChanged); maxValueInSequenceErrorProvider = new ErrorProvider(); maxValueInSequenceErrorProvider.SetIconAlignment(txtbMaxWartosc, ErrorIconAlignment.MiddleLeft); maxValueInSequenceErrorProvider.SetIconPadding(txtbMaxWartosc, 2); maxValueInSequenceErrorProvider.BlinkRate = 500; maxValueInSequenceErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; txtbMaxWartosc.TextChanged += new EventHandler(txtbMaxWartosc_TextChanged); amountOfValuesInSequenceErrorProvider = new ErrorProvider(); amountOfValuesInSequenceErrorProvider.SetIconAlignment(txtbIloscLiczb, ErrorIconAlignment.MiddleRight); amountOfValuesInSequenceErrorProvider.SetIconPadding(txtbIloscLiczb, 2); amountOfValuesInSequenceErrorProvider.BlinkRate = 500; amountOfValuesInSequenceErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; txtbIloscLiczb.TextChanged += new EventHandler(txtbIloscLiczb_TextChanged); }
public static string validateDate(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); string automatedValue = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != automatedValue && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Date shown is not formatted to the current date & time(yyyy-MM-dd hh:mm:ss)."); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); return("Blank"); } }
/// <summary> /// Constructor /// </summary> public PilotDataLoaderForm() { InitializeComponent(); _startTourErrorProvider = new ErrorProvider(); _startTourErrorProvider.SetIconAlignment(txtbxStartTour, ErrorIconAlignment.MiddleRight); _startTourErrorProvider.SetIconPadding(txtbxStartTour, 2); _startTourErrorProvider.BlinkRate = 700; _startTourErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; _endTourErrorProvider = new ErrorProvider(); _endTourErrorProvider.SetIconAlignment(txtbxEndTour, ErrorIconAlignment.MiddleRight); _endTourErrorProvider.SetIconPadding(txtbxEndTour, 2); _endTourErrorProvider.BlinkRate = 700; _endTourErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; _pilotNameErrorProvider = new ErrorProvider(); _pilotNameErrorProvider.SetIconAlignment(txtbxPilotToLoad, ErrorIconAlignment.MiddleRight); _pilotNameErrorProvider.SetIconPadding(txtbxPilotToLoad, 2); _pilotNameErrorProvider.BlinkRate = 700; _pilotNameErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; _tourTypeSelectorErrorProvider = new ErrorProvider(); _tourTypeSelectorErrorProvider.SetIconAlignment(txtbxPilotToLoad, ErrorIconAlignment.MiddleRight); _tourTypeSelectorErrorProvider.SetIconPadding(txtbxPilotToLoad, 2); _tourTypeSelectorErrorProvider.BlinkRate = 700; _tourTypeSelectorErrorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; }
public static void validateMapNumber(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { Match match = Regex.Match(control.Text, @"MA\d\d\d"); eprWarning.SetIconPadding(control, 3); eprError.SetIconPadding(control, 3); //Run the validation if (validateEmptyField(control, eprWarning)) { // Here we check the regex match if (!match.Success) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Map number does not conform to naming standard. i.e. MA001"); } else { eprError.SetError(control, ""); } } else { eprError.SetError(control, ""); validateEmptyField(control, eprWarning); } }
public static bool SetErrorProvidertoControl(ref ErrorProvider ep, ref NumericUpDown 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.BackColor = 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.BackColor = System.Drawing.Color.Red; return(false); } else if ((int)textBox.Value == 0) { ep.SetError(textBox, errorMessage); ep.SetIconAlignment(textBox, ErrorIconAlignment.MiddleRight); ep.SetIconPadding(textBox, 2); ep.BlinkRate = 1000; ep.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; //textBox.BackColor = System.Drawing.Color.Red; return(false); } else { ep.SetError(textBox, string.Empty); // textBox.BackColor = DefaultBorderColor; return(true); } return(false); } catch (Exception) { throw; } }
public void Clear(ErrorProvider errorProvider, Control control) { errorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); // moves icon in from the right errorProvider.SetIconPadding(control, -10); // w/o this, icon never clears errorProvider.SetError(control, ""); }
/// <summary> /// Initialise un composant ErrorProvider avec le choix de l'icone /// </summary> /// <param name="err">Le composant ErrorProvider à initialiser</param> /// <param name="ctrl">Le controle sur lequel faire apparaitre l'erreur</param> /// <param name="icon">L'icone à afficher</param> private void initializeError(ErrorProvider err, Control ctrl, Icon icon) { err.SetIconAlignment(ctrl, ErrorIconAlignment.MiddleRight); err.SetIconPadding(ctrl, 2); err.Icon = icon; err.BlinkRate = 250; err.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.AlwaysBlink; }
public static void SetupErrorProvider(out ErrorProvider errorProvider, Control control) { errorProvider = new ErrorProvider(); errorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); errorProvider.SetIconPadding(control, 2); errorProvider.BlinkRate = 1000; errorProvider.BlinkStyle = ErrorBlinkStyle.AlwaysBlink; }
/// <summary> /// Valida o campo como obrigatório ou não /// </summary> /// <returns>Valido true/false</returns> public bool ValidarCampos() { Funcoes func; if (bObrigatorio && !string.IsNullOrEmpty(this.ControlSource) && Propriedades.FormMain != null && Propriedades.FormMain.ActiveMdiChild != null && func.Check_Extension(Propriedades.FormMain.ActiveMdiChild.GetType(), typeof(FormSet))) { FormSet f_MdiActivate = ((FormSet)Propriedades.FormMain.ActiveMdiChild); //-- Caso o campo seja para validação execute o HelpProvider. //-- Verifica qual é o modo do formulário, permitindo apenas como Novo ou Modificando. if (f_MdiActivate.FormStatus == TipoFormStatus.Novo || f_MdiActivate.FormStatus == TipoFormStatus.Modificando) { string sValor_Valida = string.Empty; //-- Verifica o registro foi preenchido. if (sTabela.Equals(f_MdiActivate.MainTabela.ToLower())) { if (!this.IsHandleCreated || !this.Parent.IsHandleCreated) { DataRowView row = (DataRowView)f_MdiActivate.BindingSource[sTabela].Current; sValor_Valida = row[sControlSource].ToString(); } else { sValor_Valida = this.Value; } } //-- Verifica se o valor está OK. if (string.IsNullOrEmpty(sValor_Valida)) { ep.SetIconAlignment(this, ErrorIconAlignment.MiddleRight); ep.SetIconPadding(this, -19); ep.SetError(this, sMensagemObrigatorio); return(false); } else { ep.SetError(this, ""); return(true); } } else { ep.SetError(this, ""); return(true); } } else { return(true); } }
public static void whiteSpace(TextBox textBox, ref bool validate, string messeger, PictureBox pictureBox, ErrorProvider errorProvider1) { if (textBox.Text == "") { validate = false; errorProvider1.SetError(pictureBox, messeger); errorProvider1.SetIconPadding(pictureBox, 2); } }
private static void ShowError(Control control, string message) { var errorProvider = new ErrorProvider(); errorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); errorProvider.SetIconPadding(control, 2); errorProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink; errorProvider.SetError(control, message); }
public void SetErrorProvider(ErrorProvider errorProvider) { if (null == errorProvider) { throw new ArgumentNullException(nameof(errorProvider)); } errorProvider.SetIconPadding(this, -35); }
public static void validateComboBox(ComboBox comboBox, ref bool validate, string messeger, string description, ErrorProvider errorProvider1) { if (comboBox.Text == description) { validate = false; errorProvider1.SetError(comboBox, messeger); errorProvider1.SetIconPadding(comboBox, 2); } }
public frmEditUser(User user) { InitializeComponent(); this.user = user; err = new ErrorProvider(); err.BlinkStyle = ErrorBlinkStyle.NeverBlink; err.SetIconAlignment(cbRoles, ErrorIconAlignment.MiddleRight); err.SetIconPadding(cbRoles, 2); }
/// <summary> /// Valida o campo como obrigatório ou não /// </summary> /// <returns>Valido true/false</returns> public bool ValidarCampos() { Funcoes func; if (bObrigatorio && !string.IsNullOrEmpty(sControlSource) && Propriedades.FormMain != null && Propriedades.FormMain.ActiveMdiChild != null && func.Check_Extension(Propriedades.FormMain.ActiveMdiChild.GetType(), typeof(FormSet))) { FormSet f_MdiActivate = ((FormSet)Propriedades.FormMain.ActiveMdiChild); //-- Caso o campo seja para validação execute o HelpProvider. //-- Verifica qual é o modo do formulário, permitindo apenas como Novo ou Modificando. if (f_MdiActivate.FormStatus == CompSoft.TipoFormStatus.Novo || f_MdiActivate.FormStatus == CompSoft.TipoFormStatus.Modificando) { string sValor_Combo = string.Empty; //-- Verifica se o controle já existe em memoria, caso exista captura o valor do controle. if (!this.IsHandleCreated) { DataRowView row = (DataRowView)f_MdiActivate.BindingSource[sTabela].Current; sValor_Combo = row[sControlSource].ToString(); } else { if (this.Value != null) { sValor_Combo = this.Value.ToString(); } } if (string.IsNullOrEmpty(sValor_Combo)) { ep.SetIconAlignment(this, ErrorIconAlignment.MiddleRight); ep.SetIconPadding(this, -35); ep.SetError(this, sMensagemObrigatorio); return(false); } else { ep.SetError(this, ""); return(true); } } else { ep.SetError(this, ""); return(true); } } else { return(true); } }