HeaderPane
Main
Hide
Share Link
Print

Text and Values

The contents of an SftMask control are available as text, with or without the literals of the mask, as the number of a numeric field, as the values of the mask's value tokens, and position by position.

Text

MemberDescription
SftMask.TextThe contents in the form defined by the SftMask.TextFormat property, with the literals by default.
SftMask.TextWithLiteralsThe contents including the literals.
SftMask.TextNoLiteralsThe contents without the literals.
SftMask.GetTextThe contents in a given form.

The TextFormatEnum enumeration defines the forms: with or without the literals, and with empty input positions as spaces or as the prompt character. The literals are the constant characters of the mask and the group separators of numeric fields. A numeric field contributes its number without the empty positions in front of it, and an empty numeric field nothing, or one prompt character in the forms with prompts; without the literals, a negative number in parentheses is written with a minus sign. The SftMask.ClipboardFormat property defines the form of text copied to the clipboard.

Setting a text types its characters into the mask: a literal character of the text moves past the same literal of the mask, a space or the prompt character leaves an input position empty, and characters that do not fit are left out and raise the SftMask.InputRejected event. Setting the text does not set the SftMask.Modified property, which tells whether the user changed the contents.

ExampleMask \([M1-9]##\) ###\-####, user typed 5555550123
TextWithLiterals(555) 555-0123
TextNoLiterals5555550123

Numbers

The SftMask.Value property reads and sets the first numeric field as a nullable decimal (see Numeric Fields).

Value Tokens

A mask can mark parts of its contents with value tokens, !0 to !9 at the start of a part and !! at its end (see Edit Masks). The SftMask.Values property reads and sets these parts: a part that covers exactly one numeric field is a decimal (null when the field is empty), any other part is its text without literals, with spaces for empty positions. Setting a value replaces that part of the contents; a decimal is formatted with the control's culture. The ValueCollectionClass.Contains method tells whether the mask has a value token; reading a value token the mask does not have returns null, and setting it throws an ArgumentException.

C#

sftMask1.Mask = @"!1$I^03(0,255)!!\.!2$I^03(0,255)!!";
sftMask1.Values[1] = 192m;
sftMask1.Values[2] = 168m;
object first = sftMask1.Values[1];

VB

SftMask1.Mask = "!1$I^03(0,255)!!\.!2$I^03(0,255)!!"
SftMask1.Values(1) = 192D
SftMask1.Values(2) = 168D
Dim first As Object = SftMask1.Values(1)

Positions

The SftMask.Positions property describes each position of the mask: whether it is a literal, an input position, part of a numeric field, optional or a password position, and the character it holds. Its counts tell how many input positions are filled and how many are empty.

PropertyDescription
SftMask.IsEmptyNo input position holds a character.
SftMask.IsFullEvery input position holds a character and every numeric field a number.
SftMask.IsCompleteEvery required input position and every numeric field holds input. The ranges of numeric fields and the SftMask.CustomValidation event are not considered; the SftMask.IsValid property considers them (see Validation).

Events and Data Binding

The TextChanged event occurs when the contents change, and the SftMask.TextWithLiteralsChanged, SftMask.TextNoLiteralsChanged and SftMask.ValueChanged events when the corresponding property changes. Each of these properties can be bound to a data source with the control's DataBindings collection, for example the Value property to a decimal column.