Version

MaskInput Property

Returns or sets the input mask associated with the masked edit control.
Syntax
'Declaration
 
Public Property MaskInput As String
public string MaskInput {get; set;}
Remarks

When an input mask is defined, placeholders are defined by the PromptChar property. When inputting data, the user can only replace a placeholder with a character that is of the same type as the one specified in the input mask. If the user enters an invalid character, the control rejects the character. The control can distinguish between numeric and alphabetic characters for validation, but cannot validate for valid content, such as the correct month or time of day.

The input mask can consist of the following characters:

Character

Description

#

Digit placeholder. Character must be numeric (0-9) and entry is required.

.

Decimal placeholder. The actual character used is the one specified as the decimal placeholder by the system's international settings. This character is treated as a literal for masking purposes.

,

Thousands separator. The actual character used is the one specified as the thousands separator by the system's international settings. This character is treated as a literal for masking purposes.

: Time separator. The actual character used is the one specified as the time separator by the system's international settings. This character is treated as a literal for masking purposes
/ Date separator. The actual character used is the one specified as the date separator by the system's international settings. This character is treated as a literal for masking purposes.
\ Treat the next character in the mask string as a literal. This allows you to include the '#', '&', 'A', and '?' as well as other characters with special meanings in the mask. This character is treated as a literal for masking purposes.
& Character placeholder. Valid values for this placeholder are ANSI characters in the following ranges: 32-126 and 128-255 (keyboard and foreign symbol characters).
> Convert all the characters that follow to uppercase.
< Convert all the characters that follow to lowercase.
A Alphanumeric character placeholder. For example: a-z, A-Z, or 0-9. Character entry is required.
a Alphanumeric character placeholder. For example: a-z, A-Z, or 0-9. Character entry is not required.
9 Digit placeholder. Character must be numeric (0-9) but entry is not required.
- Minus sign when followed by a number section defined by series of 'n's (like in "-nn,nnn.nn") indicates that negative numbers are allowed. When not followed by a series of 'n's, it's taken as a literal. Minus sign will only be shown when the number is actually negative.
+ Plus sign when followed by a number section defined by series of 'n's (like in "-nn,nnn.nn") indicates that negative numbers are allowed. However, it differs from '-' in the respect that it will always show a '+' or a '-' sign depending on whether the number is positive or negative.
C Character or space placeholder. Character entry is not required. This operates exactly like the '&' placeholder, and ensures compatibility with Microsoft Access.
? Letter placeholder. For example: a-z or A-Z. Character entry is not required.
n Digit placeholder. A group of n's can be used to create a numeric section where numbers are entered from right to left. Character must be numeric (0-9) but entry is not required.
mm, dd, yy Combination of these three special tokens can be used to define a date mask. mm for month, dd for day, yy for two digit year and yyyy for four digit year. Examples: mm/dd/yyyy, yyyy/mm/dd, mm/yy.
hh, mm, ss, tt Combination of these three special tokens can be used to define a time mask. hh for hour, mm for minute, ss for second, and tt for AP/PM. Examples: hh:mm, hh:mm tt, hh:mm:ss.
{date} {date} token is a place holder for short date input. The date mask is derived using the underlying culture settings.
{time} {time} token is a place holder for short time input. Short time typically does not include the seconds portion. The time mask is derived using the underlying culture settings.
{longtime} {longtime} token is a place holder for long time input. Long time typically includes the seconds portion. The long time mask is derived using the underlying culture settings.
{double:i.f:c} {double:i.f:c} is a place holder for a mask that allows floating point input where i and f in i.f specify the number of digits in the integer and fraction portions respectively. The :c portion of the mask is optional and it specifies that the inputting of the value should be done continous across fraction and integer portions. For example, with :c in the mask, in order to enter 12.34 the user types in "1234". Notice that the decimal separator character is missing. This allevietes the user from having to type in the decimal separator.
{double:-i.f:c} Same as {double:i.f:c} except this allows negative numbers.
{currency:i.f:c} Same as {double:i.f:c} except the mask is constructed based on currency formatting information of the underlying format provider or the culture. It typically has the currency symbol and also displays the group characters.
{currency:-i.f:c} Same as {currency:i.f:c} except this allows negative numbers.
Literal All other symbols are displayed as literals; that is, they appear as themselves.

You can also escape the mask with {LOC} character sequence to indicate that symbols in the following table should be mapped to the associated symbols in the underlying culture settings.

Character

Description

$ Currency symbol.
/ Date seperator.
: Time seperator.
, Thousands seperator.
. Decimal seperator.
+ Positive sign.
- Negative sign.

Example
Following code shows how to use masked input functionality in the UltraGrid. It sets various mask related proeprties.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Button17_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button17.Click

      Dim column As UltraGridColumn = Me.ultraGrid1.DisplayLayout.Bands(0).Columns("Phone")

      ' Enable masked input in a column by setting the MaskInput property.
      column.MaskInput = "(###) ###-####"

      ' Set various mask modes. These mask modes effect how what is included when data
      ' is committed to the cell, when it's displayed and when it's copied. MaskMode of
      ' Raw does not include literals and prompt characters. So for this particular mask,
      ' only thig that is going to be put in the data source will be just the digits, 
      ' Literals will be stripped out (in this example, literals are '(', ')', ' ', '-' 
      ' characters.)
      column.MaskDataMode = MaskMode.Raw
      column.MaskDisplayMode = MaskMode.IncludeBoth
      column.MaskClipMode = MaskMode.IncludeLiterals

      ' PadChar and PromptChar properties effect which characters are used as pad character
      ' and prompt character in masked input cells. Padchar is the character that gets 
      ' substituted in place of an empty character when the MaskMode of 
      ' IncludeLiteralsWithPadding is applied. PromptChar is the character that's used
      ' for prompting. Default for PadChar is ' ' (space character) and for PromptChar is
      ' '_' (an underscore).
      Me.ultraGrid1.DisplayLayout.Bands(0).Columns(0).PadChar = " "
      Me.ultraGrid1.DisplayLayout.Bands(0).Columns(0).PromptChar = "_"

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void button17_Click(object sender, System.EventArgs e)
{

	UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns["Phone"];

	// Enable masked input in a column by setting the MaskInput property.
	column.MaskInput = "(###) ###-####";

	// Set various mask modes. These mask modes effect how what is included when data
	// is committed to the cell, when it's displayed and when it's copied. MaskMode of
	// Raw does not include literals and prompt characters. So for this particular mask,
	// only thig that is going to be put in the data source will be just the digits, 
	// Literals will be stripped out (in this example, literals are '(', ')', ' ', '-' 
	// characters.)
	column.MaskDataMode    = MaskMode.Raw;
	column.MaskDisplayMode = MaskMode.IncludeBoth;
	column.MaskClipMode    = MaskMode.IncludeLiterals;

	// PadChar and PromptChar properties effect which characters are used as pad character
	// and prompt character in masked input cells. Padchar is the character that gets 
	// substituted in place of an empty character when the MaskMode of 
	// IncludeLiteralsWithPadding is applied. PromptChar is the character that's used
	// for prompting. Default for PadChar is ' ' (space character) and for PromptChar is
	// '_' (an underscore).
	this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].PadChar = ' ';
	this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].PromptChar = '_';

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also