A number of new properties have been added to the TextEdit control to improve its usability. Foremost among the additions are the properties that allow for edit masks to be enforced on data input.

Edit Masks

The first property to consider is the Mask itself. This value is specified by a series of characters made up of literal characters that cannot be replaced by input characters and special characters that are replaced by a specific set of input characters. The following list show valid replaceable mask characters and the valid characters they represent.


Mask Character Valid Inputs
   9    Digits 0-9 or blank (entry not required)
   0    Digits 0-9 (entry required)
   L    Alpha character (entry required)
   ?    Alpha character (entry not required)
   A    Alpha-numeric character (entry required)
   a    Alpha-numeric character (entry not required)
   &    Any character or space (entry required)
   C    Any character or space (entry not required)
   #    Digits 0-9,+, - or blank (entry not required)


An example of an edit mask is (999) 000-0000 for a U.S. phone number. At entry time, the parenthesis would become part of the data and cannot be overwritten by input characters while the 0's and 9's would be replaced.

To specify what character should represent an available entry spot in the mask, use the Mask Entry Char property, which by default is set to the underscore (_) character. This character will represent the replaceable character locations.

Further control over the entered data can be accomplished using the Char Case property which can be set to one of the three properties ccLowerCase, ccNoChange, or ccUpperCase. Setting this will respectively change the characters to lower case, make no change or change to upper case as they are entered. Also the case changes will be applied to whatever the initial value of Text is for the TextEdit box.

To set all of these properties at once at design time, the dialog box shown in figure 1 can be displayed by clicking the ellipses button at the end of the Mask property. A number of sample masks (number 1) are available to be used by clicking on one of them to fill the input mask field (number 2) or any input mask may be entered in the field. The character to represent replaceable characters is specified in the Character for Blanks field (number 3).

Three option buttons are available in the Text Case group (number 4) and a Test Input field that can be used to validate that the mask works as expected by number 5. Finally the mask can be added to the Sample Masks list by clicking the Add Mask button (number 6) which will give it the name Custom in the list. Right-clicking in the list box will bring up a popup menu which has options Load Masks from a file, Save Masks to a file or Delete the highlighted masks. Being able to save and load masks means that masks can be shared among projects.


textedit-mask-edit.png
Figure 1: Edit Mask dialog box

Additional Information

The new property Empty Text controls what text is displayed in the TextEdit box when it contains no Text value. The Empty Text is automatically cleared as soon as soon as the cursor enter the edit box and is replaced with the edit mask if there is one.

Checking the Is Password property will hide any input mask and make it extremely difficult for users to understand what is going on when entering characters.

Setting the Max Length property has no effect if a Mask is specified.


Related Topics

Back to top