HeaderPane
Main
Hide
Share Link
Print

Common Masks

The following masks cover common data entry fields. The property pages offer most of them as predefined masks (see Control Properties); the syntax is described in Edit Masks.

FieldMaskSettings
Phone number\([M1-9]##\) ###\-####
Phone number with extension\([M1-9]##\) ###\-#### x9999
Social security number###\-##\-####
ZIP code#####
ZIP+4 code#####\-9999
Amount with calculator$^C-,8.2Label "|" (the currency symbol), TextAlign Right, ButtonStyle UpDown
Percentage$^3(0,100)Label "%", LabelPosition Right, ButtonStyle UpDown
Quantity$I^N,5(0,10000)ButtonStyle UpDown
IP address$I^03(0,255)\.$I^03(0,255)\.$I^03(0,255)\.$I^03(0,255)TabAdvance, AutoAdvance
Hexadecimal color\#$X06
Credit card number####=####=####=####
License key<uAAAAA\-AAAAA\-AAAAA>
PIN<p####>UseSystemPasswordChar

Setting a Mask in Code

C#

sftMask1.Mask = @"\([M1-9]##\) ###\-####";

sftMask2.Mask = "$^C-,8.2";
sftMask2.Label = "|";
sftMask2.TextAlign = HorizontalAlignment.Right;
sftMask2.ButtonStyle = ButtonStyleEnum.UpDown;
sftMask2.Value = 1234.5m;

VB

SftMask1.Mask = "\([M1-9]##\) ###\-####"

SftMask2.Mask = "$^C-,8.2"
SftMask2.Label = "|"
SftMask2.TextAlign = HorizontalAlignment.Right
SftMask2.ButtonStyle = ButtonStyleEnum.UpDown
SftMask2.Value = 1234.5D

Setting a number through the SftMask.Value property, rather than the SftMask.Text property, keeps the code independent of the culture's decimal separator.