property Editor.Mask as String
Retrieves or sets a value that indicates the mask used by the editor.

 TypeDescription 
   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 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_g2antt.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 = EXG2ANTTLib.EditTypeEnum.MaskType
        .Mask = "(###) ### - ####"
    End With
End With

The following C# adds a mask editor to filter characters while entering a phone number:

EXG2ANTTLib.Items items = axG2antt1.Items;
EXG2ANTTLib.Editor editor = items.get_CellEditor(items.FirstVisibleItem, 0);
editor.EditType = EXG2ANTTLib.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



Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.