Custom Input Masks (Text)

Metacharacters

 

Metacharacters are used to represent a range of symbols. An end-user can enter text only in the positions which correspond to metacharacters.  When a metacharacter is found at a specific position in the mask an end-user can enter any character from the related range in this position in the edit box.  The following table lists the available metacharacters:

 

Character

Meaning

L

An L character requires an alphabetic character in this position. For the U.S. this is A-Z, a-z.

l

An l character permits only an alphabetic character in this position, but doesn't require it.

A

An A character requires an alphanumeric character in this position. For the U.S. this is A-Z, a-z, 0-9.

a

An a character permits only an alphanumeric character in this position, but doesn't require it.

C

A C character requires an arbitrary character in this position.

c

A c character permits an arbitrary character in this position, but doesn't require it.

0

A 0 character requires a numeric character in this position.

9

A 9 character permits only a numeric character in this position, but doesn't require it.

#

A # character permits only a numeric character or a plus or minus sign in this position, but doesn't require it.

Special Characters

 

The following table lists the available special characters which are used to control the case of the input string and to represent various delimiters and currency symbols.

 

Character

Meaning

>

If a > character appears in the mask, all the characters that follow it are in uppercase until the end of the mask or until a < character is encountered.

<

If a < character appears in the mask, all the characters that follow it are in lowercase until the end of the mask or until a > character is encountered.

<>

If these two characters appear together in a mask, no case checking is performed and the data is formatted with the case used by the end-user during data entry.

/

A / character is used to separate the months, days, and years in dates.  If the character that separates the months, days, and years is different in the regional settings of the system that the application runs on that character will be used instead.

:

A : character is used to separate the hours, minutes, and seconds in time values.  If the character that separates the hours, minutes, and seconds is different in the regional settings of the system that the application runs on that character will be used instead.

$

A $ character is used to designate currency values.  If the character that designates the currency values is different in the regional settings of the system that the application runs on that character is used instead.

 

Literal Characters

 

A character that is neither a metacharacter nor a special character is called a literal.  Literals are inserted automatically as is into the edit box in their positions defined by the mask.  An end-user has no need to enter literal characters.  The cursor skips over them during editing.

The metacharacters and special characters can also appear as literal characters if they are preceded by a backslash (\).

 

Examples

 

  1. A mask for entering a telephone number:  (000)000-00-00.

Each '0' metacharacter in this mask requires a numeric character in the corresponding position.  No characters can be omitted. The '-', '(' and ')'characters in the mask are literals.

The following are images of an editor that uses this mask:

Description: http://documentation.devexpress.com/HelpResource.ashx?help=WindowsForms&document=img4110.jpg (a value is not entered)

Description: http://documentation.devexpress.com/HelpResource.ashx?help=WindowsForms&document=img4111.jpg (a value is entered)

  1. A mask for entering a telephone number with an optional area code:  (999)000-00-00

Here the '9' metacharacter allows end-users to omit the area code part of a phone number.

Description: http://documentation.devexpress.com/HelpResource.ashx?help=WindowsForms&document=img4100.jpg (a valid phone number without a code part)

3.       A mask for entering an alpha-numeric sequence:  \A>LL-00

Here '\A' stands for the literal character 'A'. Since 'A' is used as a metacharacter the backslash must be used to make 'A' appear as a literal. The '>' command specifies that the following text should be in uppercase. The 'LL' substring indicates that two alphabetical characters should be inserted in this position. The '00' substring is a placeholder for two digits.

Description: http://documentation.devexpress.com/HelpResource.ashx?help=WindowsForms&document=img4112.jpg (a value is not entered)

Description: http://documentation.devexpress.com/HelpResource.ashx?help=WindowsForms&document=img4113.jpg (a value is entered)

Note:  When a text input mask is enabled, any new attributes that are indexed will store the mask characters along with the data.  Historical data that has already been indexed before the mask was created will have the mask applied when displaying the fields but the underlying data will remain unchanged.