Returns or sets the input mask used to edit cells.
Syntax
[form!]VSFlexGrid.EditMask[ = value As String ]
Remarks
The EditMask property allows you to specify an input mask for automatic input formatting and validation. The mask syntax is similar to the one used by the Microsoft MaskedEdit control and by Microsoft Access.
Set the EditMask property in response to the BeforeEdit event, in the same way you would set the ComboList property.
If the same mask is used to edit all values in a column, use the ColEditMask property instead. This tends to simplify the code because you don't need to trap the BeforeEdit event.
When the user is done editing, the ValidateEdit event will be fired as usual. The Cancel parameter will be set to True if the mask was not filled out properly, so in most cases you don't event need to implement the handler. The default behavior ensures that only valid data will be entered.
The EditMask must be a string composed of the following symbols:
Wildcards
0 digit
9 digit or space
# digit or sign
L letter
? letter or space
A letter or digit
a letter, digit, or space
& any character
Localized characters
. localized decimal separator
, localized thousand separator
: localized time separator
/ localized date separator
Command characters
\ next character is taken as a literal (not a special character)
> translate letters to uppercase
< translate letters to lowercase
; group delimiter (see below)
The group delimiter character is used to control additional options. If present in the mask string, then the part of the mask to the left of the first delimiter is used as the actual mask. The part to the right is interpreted in this way:
If a lowercase 'q' is present, the control edits in 'quiet' mode (no beeps on invalid characters),
The last character is used as a placeholder (instead of the default underscore).
For example:
' set the mask so the user can enter a phone number,
' with optional area code, and a state in capitals.
' this will beep on invalid keys.
fg.EditMask = "(###) 000-0000 St\ate\: >LL"
' similar mask, but in quiet mode (no beep for wrong keys)
' and with an asterisk instead of underscore for a placeholder:
fg.EditMask = "(###) 000-0000 St\ate\: >LL;q;*"
Here are some more commented examples:
EditMask String |
Description |
"St\ate\; >LL" |
Is a valid format. The 'a' and ';' characters are escaped and thus taken as literals. The '>' is used to ensure that the next two characters will be represented in uppercase. |
"St\ate\; >LL;q;*" |
Is a valid format. It is similar to the previous example, but the 'q' after the delimiter puts the control in quiet mode. An asterisk '*' is used as placeholder instead of the underscore, because that is the last character after the delimiter. |
"St; >LL" |
This is an invalid format. The mask itself is just "St" (the part to the left of the ';' delimiter. There are no wildcards, so the user can't type anything. If he could, the placeholder character would be "L" (last character after the ';' delimiter). |
"; >LL" |
This is an invalid format. The first character is a delimiter, so there is no real mask at all. |
Data Type
String