private void RemoveCharactersAndReplaceWithMaskPrompt() { MaskFormat maskFormat = TextMaskFormat; // Set to include prompts and literals; TextMaskFormat = MaskFormat.IncludePromptAndLiterals; char[] newText = base.Text.ToCharArray(); int savePos = SelectionStart; // Clear the selected non-delimiter fields. for (int i = SelectionStart; i < SelectionStart + SelectionLength; i++) { if (posToMaskIndex.Length > 0) { if (posToMaskIndex[i] >= 0) { newText[i] = PromptChar; } } else { newText[i] = ' '; } } // Handle MaskedTextBox quirk when the text has whitespace. Text = StripSpaces(new String(newText)); TextMaskFormat = maskFormat; SelectionStart = savePos; SelectionLength = 0; }
/// <summary> /// On leave, clear the mask, allowing the control /// to display the null display value text if the /// control is in the null state. /// </summary> protected override void OnLeave(EventArgs e) { // Save text mask format. MaskFormat maskFormat = TextMaskFormat; // Set to exclude all. TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; // If the Text is an empty string, then replace with the null text display value. if (base.Text == String.Empty) { // The mask has to be cleared. Mask = String.Empty; // Set the textbox to display the null text display value. Text = nullTextDisplayValue; // Our control value is the null value. Value = nullValue; } else { // valid text, set our control value to the Text property value. Value = base.Text; } // Restore the text mask format. TextMaskFormat = maskFormat; base.OnLeave(e); }
/// <summary> /// Constructor for the KryptonDataGridViewMaskedTextBoxCell cell type /// </summary> public KryptonDataGridViewMaskedTextBoxCell() { // Create a thread specific KryptonMaskedTextBox control used for the painting of the non-edited cells if (_paintingMaskedTextBox == null) { _paintingMaskedTextBox = new KryptonMaskedTextBox(); _paintingMaskedTextBox.SetLayoutDisplayPadding(new Padding(0, 0, 1, -1)); _paintingMaskedTextBox.StateCommon.Border.Width = 0; _paintingMaskedTextBox.StateCommon.Border.Draw = InheritBool.False; _paintingMaskedTextBox.StateCommon.Back.Color1 = Color.Empty; } // Set the default values of the properties: _promptChar = '_'; _allowPromptAsInput = true; _asciiOnly = false; _beepOnError = false; _cutCopyMaskFormat = MaskFormat.IncludeLiterals; _hidePromptOnLeave = false; _hideSelection = true; _insertKeyMode = InsertKeyMode.Default; _mask = string.Empty; _passwordChar = '\0'; _rejectInputOnFirstFailure = false; _resetOnPrompt = true; _resetOnSpace = true; _skipLiterals = true; _textMaskFormat = MaskFormat.IncludeLiterals; _useSystemPasswordChar = false; }
private void Init() { BackColor = SystemColors.Window; cut_copy_mask_format = MaskFormat.IncludeLiterals; insert_key_overwriting = false; UpdateVisibleText(); }
public static string obterStringSemMascara(MaskedTextBox tb) { string ret = null; MaskFormat prev = tb.TextMaskFormat; tb.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; ret = tb.Text; tb.TextMaskFormat = prev; return(ret); }
// ---- ENDERECO public static String obterConteudo(Control control) { String conteudo = control.Text; if (control is MaskedTextBox mtb) { MaskFormat oldFormat = mtb.TextMaskFormat; String oldText = mtb.Text; mtb.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; conteudo = mtb.Text; mtb.Text = oldText; mtb.TextMaskFormat = oldFormat; } return(conteudo); }
string GetPureDateText() { // get pure text MaskFormat oldformat = this.maskedTextBox_date.TextMaskFormat; this.IngoreTextChange++; this.maskedTextBox_date.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; string strPureText = this.maskedTextBox_date.Text; this.maskedTextBox_date.TextMaskFormat = oldformat; this.IngoreTextChange--; return(strPureText); }
/// <summary> /// Recupera o caractere indicador de formato para exibição. /// </summary> /// <param name="instance"></param> /// <returns></returns> public static char GetFormatChar(this MaskFormat instance) { switch (instance) { case MaskFormat.Digit: return('0'); case MaskFormat.DigitOption: return('#'); case MaskFormat.Ascii: return('L'); case MaskFormat.AsciiOption: return('?'); case MaskFormat.Unicode: return('&'); case MaskFormat.UnicodeOption: return('C'); case MaskFormat.AlphaNumeric: return('A'); case MaskFormat.AlphaNumericOption: return('a'); case MaskFormat.Fractional: return('.'); case MaskFormat.Thousands: return(','); case MaskFormat.Lowercase: return('<'); case MaskFormat.Uppercase: return('>'); case MaskFormat.Escape: return('\\'); } return(' '); }
private DateTime get_vData() { MaskFormat msk = this.TextMaskFormat; try { this.TextMaskFormat = MaskFormat.IncludePromptAndLiterals; return(Convert.ToDateTime(this.Text)); } catch { return(new DateTime()); } finally { this.TextMaskFormat = msk; } }
private void btnEntrar_Click(object sender, EventArgs e) { btnEntrar.Enabled = false; MaskFormat format = txtCpf.TextMaskFormat; String Cpf = txtCpf.Text.Trim(); String Password = txtPassword.Text; txtCpf.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; if (!User.ValidateCpf(txtCpf.Text.Trim())) { MessageBox.Show("CPF inválido!"); txtCpf.Focus(); } else { User user = null; DAOUser dao = new DAOUser(); user = dao.DoLogin(Cpf, Password); if (user is User) { WalletPanel panel = new WalletPanel(this, user); panel.Show(); this.Visible = false; } else { MessageBox.Show("CPF ou senha inválidos."); } } txtCpf.TextMaskFormat = format; btnEntrar.Enabled = true; }
/// <summary> /// Indica se o formato é um caractere fixo. /// </summary> /// <param name="instance"></param> /// <returns></returns> public static bool IsSeparator(this MaskFormat instance) { return((instance == MaskFormat.Separator) || (instance == MaskFormat.Fractional) || (instance == MaskFormat.Thousands)); }
private void Init () { BackColor = SystemColors.Window; cut_copy_mask_format = MaskFormat.IncludeLiterals; insert_key_overwriting = false; UpdateVisibleText (); }
/// <summary> /// Identifica se a posição tem preenchimento obrigatório. /// </summary> /// <param name="instance"></param> /// <returns></returns> public static bool IsRequired(this MaskFormat instance) { return((instance == MaskFormat.AlphaNumeric) || (instance == MaskFormat.Ascii) || (instance == MaskFormat.Digit) || (instance == MaskFormat.Unicode)); }
/// <summary> /// Indicador de formato alfanumérico. /// </summary> /// <param name="instance"></param> /// <returns></returns> public static bool IsAlphaNumeric(this MaskFormat instance) { return((instance == MaskFormat.AlphaNumeric) || (instance == MaskFormat.AlphaNumericOption) || (instance == MaskFormat.Ascii) || (instance == MaskFormat.AsciiOption) || (instance == MaskFormat.Digit) || (instance == MaskFormat.DigitOption)); }
private void Initialize() { TextMaskFormat = MaskFormat.IncludeLiterals; }
private bool ValidateUpdForm() { if (cbbUpdFlag.SelectedValue == null) { MessageBox.Show("Informe a bandeira do cartão."); cbbUpdFlag.Focus(); return(false); } MaskFormat number = txtUpdNumber.TextMaskFormat; MaskFormat cvc = txtUpdCvc.TextMaskFormat; MaskFormat limit = txtUpdLimit.TextMaskFormat; txtUpdNumber.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; txtUpdCvc.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; txtUpdLimit.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; if (txtUpdNumber.Text.Trim().Equals("")) { MessageBox.Show("Informe o número do cartão."); txtUpdNumber.Focus(); return(false); } if (txtUpdCvc.Text.Trim().Equals("")) { MessageBox.Show("Informe o CVC do cartão."); txtUpdCvc.Focus(); return(false); } if (cbbUpdExpireMonth.SelectedItem == null) { MessageBox.Show("Selecione o mês de validade."); cbbUpdExpireMonth.Focus(); return(false); } if (cbbUpdExpireYear.SelectedItem == null) { MessageBox.Show("Selecione o ano de validade."); cbbUpdExpireYear.Focus(); return(false); } if (txtUpdLimit.Text.Trim().Equals("")) { MessageBox.Show("Informe o limite do cartão."); txtUpdLimit.Focus(); return(false); } txtUpdNumber.TextMaskFormat = number; txtUpdCvc.TextMaskFormat = cvc; txtUpdLimit.TextMaskFormat = limit; return(true); }
/// <summary> /// Indica se o formato é de preenchimento opcional. /// </summary> /// <param name="instance"></param> /// <returns></returns> public static bool IsOptional(this MaskFormat instance) { return((instance == MaskFormat.AlphaNumericOption) || (instance == MaskFormat.AsciiOption) || (instance == MaskFormat.DigitOption) || (instance == MaskFormat.UnicodeOption)); }
/// <summary> /// Indica a possibilidade da posição ser preenchida. /// </summary> /// <param name="instance"></param> /// <returns></returns> public static bool IsPositionToFill(this MaskFormat instance) { return(instance.IsOptional() || instance.IsRequired()); }
/// <summary> /// Construtor parametrizado. /// </summary> /// <param name="value"></param> /// <param name="format"></param> /// <param name="itemCase"></param> public FormatToken(char value, MaskFormat format, MaskCase itemCase) { _value = value; _format = format; _itemCase = itemCase; }