Previous Topic

Next Topic

Inhoudsopgave

Book Index

TIsahGridMaskEdit.EditMask Property

The major feature of the MaskEdit is the edit mask that provides mask validating and the formatting of user input. MaskEdit supports three types of edit mask:

  1. Standard
  2. Regular Expressions
  3. Extended Regular Expressions

Standard

The standard edit mask is a string that consists of three fields with semicolons separating them. The first part of the mask is the mask itself. The second part is the character that determines whether literal characters within the mask are saved as part of the data. The third part of the mask is the character used to represent un-entered characters in the mask.

These are the special characters used in the first field of the mask:

Character

Description

!

Causes optional characters to be shown as leading spaces. If this character does not appear in the mask, optional characters are shown as trailing spaces.

>

Causes all following characters to be converted to upper case.

<

Causes all following characters to be concerted to lower case.

<>

Causes the use of upper case characters as specified by the user to be valid.

\

Causes the character that follows to be displayed as a literal character. Used to display any of the special characters to be used as literal characters (for example, \L is displayed as just L).

L

Letter (a through z, A through Z, entry required).

l

Letter (a through z, A through Z, entry optional).

A

Alphanumeric character (a through z, A through Z, 0 through 9, entry required).

a

Alphanumeric character (a through z, A through Z, 0 through 9, entry optional.

C

Any character or a space (entry required).

c

Any character or a space (entry optional).

0

Number (0 through 9, entry required).

9

Number (0 through 9, entry optional).

#

Number (entry optional; plus (+) and minus (-) signs also allowed).

:

Time separator for separating hours:minutes:seconds. (The character specified in the regional settings in the Windows Control Panel, Regional Settings supersedes this value).

/

Date separator for separating months/days/years. (The character specified in the regional settings in the Windows Control Panel, Regional Settings supersedes this value).

;

Mask section separator.

_

Places a space in the text. If the user types a character in this position, the cursor jumps over the _ character.

Any character not present in the table above may appear in the first part of the mask as literal characters. Literal characters must match precisely when the field is entered. These characters are inserted automatically and the cursor jumps over them when you are typing. The special characters above can also be used in this way if they are preceded by \.

The second field of the mask is a single character that indicates whether literal characters from the mask should be included as part of the text for the edit control. For example, the mask for a telephone number with area code could be the following string:

(000)_000-0000;0;*

The '0' in the second field indicates that the Text property for the edit control would consist of the 10 digits that were entered, rather than the 14 characters that make up the telephone number as it appears in the edit control.

A '0' in the second field indicates that literals should be omitted, any other character indicates that they should be included.

The third field of the mask is the character that appears in the edit control for blanks (characters that have not been entered). By default, this is the same as the character that stands for literal spaces. The two characters appear the same in an edit window. However, when a user edits the text in a masked edit control, the cursor selects each blank character in turn, and skips over the space character.

Regular Expressions

MaskEdit supports regular expressions to validate and format user input. For a complete regular expression reference see the Using Regular Expressions topic.

Extended Regular Expression

This is similar to a regular expression but with an added auto complete facility. If, while entering text into a MaskEdit a user has no alternative text to enter, the text is auto-completed to the point where an alternative appears again.

For example, the regular expression is:

\w+' 'like' '\w+' 'apples!

After a user enters, for instance 'I' and presses the space button, the text is auto completed to the following:

'I like ';

After a user enters, for instance 'red' and presses space again, the text is auto completed to the following:

'I like red apples!'