FixedMaskedTextProvider<T>

FixedMaskedTextProvider
Implements a fixed masked text provider that converts to the specified type of T, using the standard System.ComponentModel.MaskedTextProvider.
T

Constructors

FixedMaskedTextProvider

#
public FixedMaskedTextProvider(string mask, CultureInfo culture = null, bool allowPromptAsInput = true, bool restrictToAscii = false)
Initializes a new instance of the FixedMaskedTextProvider<T> class.
mask (string)Mask for the input. See FixedMaskedTextProvider.Mask for mask format.
culture (CultureInfo = null)Culture to format date/time separators and numeric placeholders.
allowPromptAsInput (bool = true)If set to true, then allow the FixedMaskedTextProvider.PromptChar as valid input.
restrictToAscii (bool = false)If set to true, restrict input characters to ASCII only (a-z or A-Z).

Properties

AllowPromptAsInput

public bool AllowPromptAsInput { get; }
Gets a value indicating whether the FixedMaskedTextProvider.PromptChar can be a valid input character by the user.
inherited fromFixedMaskedTextProvider

AsciiOnly

public bool AsciiOnly { get; }
Gets a value indicating whether the input only accepts ascii characters A-Z or a-z.
inherited fromFixedMaskedTextProvider

AutoAdvance

public bool AutoAdvance { get; set; }
Gets or sets a value indicating that the cursor position will advance past literals to the next available edit position automatically.
inherited fromFixedMaskedTextProvider

ConvertToText

#
public Func<T, string> ConvertToText { get; set; }
Gets or sets a delegate to convert the a value of type T to the mask string.

ConvertToValue

#
public Func<string, T> ConvertToValue { get; set; }
Gets or sets a delegate to convert the mask string to a value of type T

Culture

public CultureInfo Culture { get; }
Gets the culture for the mask, as specified in the constructor.
inherited fromFixedMaskedTextProvider

DisplayText

public virtual string DisplayText { get; }
Gets the display text, including prompt characters.
inherited fromFixedMaskedTextProvider

EditPositions

public IEnumerable<int> EditPositions { get; }
Gets an enumeration of all valid edit positions in the mask.
inherited fromFixedMaskedTextProvider

IncludeLiterals

public bool IncludeLiterals { get; set; }
Gets or sets a value indicating that the FixedMaskedTextProvider.Text property includes literals in the mask.
inherited fromFixedMaskedTextProvider

IncludePrompt

public bool IncludePrompt { get; set; }
Gets or sets a value indicating that the FixedMaskedTextProvider.Text property includes prompt characters for each edit position in the mask.
inherited fromFixedMaskedTextProvider

IsPassword

public bool IsPassword { get; set; }
Gets or sets a value indicating whether the mask should be password protected.
inherited fromFixedMaskedTextProvider

Mask

public string Mask { get; }
Gets the mask for this provider, as specified in the constructor.
inherited fromFixedMaskedTextProvider
Remarks: The mask format can consist of the following characters: 0 - Required digit from 0-9. 9 - Optional digit or space. # - Optional digit, space, or sign (+/-). If blank, then it is output as a space in the Text value. L - Required upper or lowercase letter. ? - Optional upper or lowercase letter. & - Required character. If FixedMaskedTextProvider.AsciiOnly is true, then behaves like L. C - Optional character. If FixedMaskedTextProvider.AsciiOnly is true, then behaves like ?. A - Required alphanumeric character. If FixedMaskedTextProvider.AsciiOnly is true, then behaves like L. a - Optional alphanumeric. If FixedMaskedTextProvider.AsciiOnly is true, then behaves like ?. . - Decimal placeholder based on the specified FixedMaskedTextProvider.Culture for the mask. , - Thousands placeholder based on the specified FixedMaskedTextProvider.Culture for the mask. : - Time separator based on the specified FixedMaskedTextProvider.Culture for the mask. / - Date separator based on the specified FixedMaskedTextProvider.Culture for the mask. $ - Currency symbol based on the specified FixedMaskedTextProvider.Culture for the mask. < - Shift all characters that follow to lower case. > - Shift all characters that follow to upper case. | - Disables a previous shift to upper or lower case. \ - Escape the following character into a literal. All other characters are treated as literal and cannot be moved or deleted.
The text mask.

MaskCompleted

public virtual bool MaskCompleted { get; }
Gets a value indicating whether the mask has all required text to pass its validation.
inherited fromFixedMaskedTextProvider

MaskFull

public virtual bool MaskFull { get; }
Gets a value indicating that all available edit positions in the mask have been filled out.
inherited fromFixedMaskedTextProvider

PasswordChar

public char PasswordChar { get; set; }
In password mode, gets or sets the character to show for filled edit characters in the mask.
inherited fromFixedMaskedTextProvider

PromptChar

[DefaultValue('_')] public char PromptChar { get; set; }
Gets or sets the character to show for each unfilled edit position in the mask.
inherited fromFixedMaskedTextProvider

SkipLiterals

public bool SkipLiterals { get; set; }
Gets or sets a value indicating that the user can type literals to skip them in the mask.
inherited fromFixedMaskedTextProvider

Text

public virtual string Text { get; set; }
Gets or sets the text, usually excluding prompt or literal characters depending on the mask provider.
inherited fromFixedMaskedTextProvider

Value

#
public T Value { get; set; }
Gets or sets the translated value of the mask.

Methods

Clear

public bool Clear(ref int position, int length, bool forward)
Called to clear a range of characters at the specified position in the masked text.
inherited fromFixedMaskedTextProvider
Remarks: The cleared characters usually show the prompt character after cleared. This is useful for fixed length mask providers. For variable length, this is usually the same as calling FixedMaskedTextProvider.Delete(int, int, bool).
position (ref int)Position to clear at.
length (int)Length of text (in the mask) to clear
forward (bool)true to delete the text forward, or false to delete backward
true when the deletion was successful, or false if it failed.
Clear

CommitText

public virtual void CommitText()
Called to update the display text after changes to the mask value.
inherited fromFixedMaskedTextProvider
Remarks: This is called after user changes to the mask value is complete, such as when the control loses focus, or when the user presses enter. This allows the mask provider to update the display text after changes are made to the value, while still allowing the user to type in the text without it changing until they are done.
CommitText

Delete

public virtual bool Delete(ref int position, int length, bool forward)
Called to delete a range of characters at the specified position in the masked text.
inherited fromFixedMaskedTextProvider
position (ref int)Position to delete at.
length (int)Length of text (in the mask) to delete
forward (bool)true to delete the text forward, or false to delete backward
true when the deletion was successful, or false if it failed.
Delete

Insert

public virtual bool Insert(char character, ref int position)
Called to insert a character at the specified position in the masked text.
inherited fromFixedMaskedTextProvider
character (char)Character to insert.
position (ref int)Position to insert at.
true when the insertion was successful, or false if it failed.
Insert

Replace

public virtual bool Replace(char character, ref int position)
Called to replace a character at the specified position in the masked text.
inherited fromFixedMaskedTextProvider
character (char)Character to insert.
position (ref int)Position to insert at.
true when the replacement was successful, or false if it failed.
Replace