![]() | 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. If the Mask property is empty no filter is applied. The Mask property is composed by a combination of regular characters, literal escape characters, and masking characters. The Mask property can contain also alternative characters, or range rules. A literal escape character is preceded by a \ character, and it is used to display a character that is used in masking rules.

Here's the list of all rules and masking characters:
The following VB sample adds a mask for IP addresses:
With Grid1
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 Grid1
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 AxGrid1.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 = axGrid1.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.Grid1.Items With .CellEditor(.FirstVisibleItem, 0) .EditType = 8 && MaskType .Mask = "(###) ### - ####" EndWith endwith