Type | Description | |||
String | A string expression that defines the editor's mask. |
Use the Mask property to filter characters during data input. Use the Mask property to control the entry of many types of formatted information such as telephone numbers, social security numbers, IP addresses, license keys etc. The Mask property has effect for the following edit types: DropDownType, SpinType, DateType, MaskType, FontType, PickEditType. The Numeric property specifies whether the editor enables numeric values only. Use the MaskChar property to change the masking character. The Mask property is composed by a combination of regular characters, literal escape characters, and placeholders, masking characters. The Mask property can contain also alternative characters, or range rules.
The following special characters are supported only in versions prior to version 12.1
Here's the list of all rules and masking characters:
The following VB sample adds a mask for IP addresses:
With G2antt1 With .Columns.Add("Mask") With .Editor .EditType = EditTypeEnum.MaskType .Mask = "{0,255}\.{0,255}\.{0,255}\.{0,255}" End With End With .Items.AddItem "193.226.40.161" End With
The following VB sample masks a phone number:
With G2antt1 With .Columns.Add("Mask") With .Editor .EditType = EditTypeEnum.MaskType .Mask = "(XXX) - XXX XXXX" End With End With .Items.AddItem "(095) - 889 1234" End With
The following C++ adds a mask editor to filter characters while entering a phone number:
#include "Items.h" #include "Editor.h" COleVariant vtMissing; V_VT( &vtMissing) = VT_ERROR; CItems items = m_grid.GetItems(); CEditor editor = items.GetCellEditor( COleVariant( items.GetFirstVisibleItem() ), COleVariant( long(0) ) ); editor.SetEditType( 8 /*MaskType*/ ); editor.SetMask("(###) ### - ####");
The following VB.NET adds a mask editor to filter characters while entering a phone number:
With AxG2antt1.Items With .CellEditor(.FirstVisibleItem, 0) .EditType = EXGRIDLib.EditTypeEnum.MaskType .Mask = "(###) ### - ####" End With End With
The following C# adds a mask editor to filter characters while entering a phone number:
EXGRIDLib.Items items = axG2antt1.Items; EXGRIDLib.Editor editor = items.get_CellEditor(items.FirstVisibleItem, 0); editor.EditType = EXGRIDLib.EditTypeEnum.MaskType; editor.Mask = "(###) ### - ####";
The following VFP adds a mask editor to filter characters while entering a phone number:
with thisform.G2antt1.Items With .CellEditor(.FirstVisibleItem, 0) .EditType = 8 && MaskType .Mask = "(###) ### - ####" EndWith endwith
Starting from the version 12.1, the Mask property is changed radically, to support more special characters, validation, float numbers, and so on.
For instance, the following input-mask ( ext-phone )
"!(999) 000 0000;1;;select=1,empty,overtype,warning=invalid character,invalid=The value you entered isn't appropriate for the input mask <b>'<%mask%>'</b> specified for this field."
indicates the following:
The four parts of an input mask, or the Mask property supports up to four parts, separated by a semicolon (;). For instance, "`Time: `00:00:00;;0;overtype,warning=<fgcolor FF0000>invalid character,beep", indicates the pattern "00:00" with the prefix Time:, the masking character being the 0, instead _, the field enters in over-type mode, insert-type mode is not allowed, and the field beeps and displays a tooltip in red with the message invalid character when the user enters an invalid character.
Input masks are made up one mandatory part and three optional parts, and each part is separated by a semicolon (;). If a part should use the semicolon (;) it must uses the \; instead
The purpose of each part is as follows:
The following table lists the placeholder and literal characters for an input mask and explains how it controls data entry:
Characters enclosed in double quotation ("" or ``) marks will be displayed literally. If this part should display/use the semicolon (;) character is should be included between double quotation ("" or ``) characters or as \; ( escape ).
The known options for the forth part are:
Experimental:
multiline, specifies that the field supports multiple lines.
rich, specifies that the field displays a rich type editor. By default, the standard edit field is shown
disabled, shows as disabled the field.