Spread Windows Forms 13.0 Product Documentation
FarPoint.Win.Spread Assembly / FarPoint.Win.Spread.CellType Namespace / MaskCellType Class / Mask Property
Example


In This Topic
    Mask Property (MaskCellType)
    In This Topic
    Gets or sets the mask string.
    Syntax
    'Declaration
     
    Public Property Mask As String
    'Usage
     
    Dim instance As MaskCellType
    Dim value As String
     
    instance.Mask = value
     
    value = instance.Mask
    public string Mask {get; set;}

    Property Value

    String containing the mask
    Remarks

    Use this property to define an input mask that prompts the user and restricts the entry to certain values. To create a mask, set this property to a string of mask characters. Each mask character represents a position in which the user can type a character. Different mask characters allow certain kinds of characters.

    A mask can consist of any combination of mask characters and literals. A literal is a character or symbol that the user cannot type over. The use of literals helps the user to enter certain kinds of values by formatted the entry. For example, the following string defines a mask for a telephone number with the parentheses and dash as literals:

    (###) ### - ####

    where each pound sign (#) allows one digit to be entered.

    The mask control provides the following mask characters:

    Character Definition
    # Allows numbers only
    A Allows letters only
    H Allows hexadecimal values (0-9, A-F) only
    L Allows only letters and makes them lowercase
    M Allows letters and makes them lowercase, and allows numbers
    N Allows numbers and letters
    U Allows only letters and makes them uppercase
    W Allows letters and makes them uppercase, and allows numbers
    X Allows any character

    For the X character, the control screens for control characters using the Microsoft .NET Framework Char.IsControl method. If the method returns false for the character, it is allowed. If the method returns true, the character is not allowed.

    The predefined mask characters are case sensitive. You must type the Mask property settings as specified (for example, "A" not "a"). To use any of the mask characters as a literal, put a backslash in front of the character. For example, if you wanted to put the word "Number" in front of the entry of a numeric value, you would have to use "\Number" since N is a pre-defined mask character. So the mask for a phone number could be:

    \Number: (###) ###-####

    What would appear in the cell would be

    Number: (___) ___-____

    if you used the default MaskChar of underscore ("_").

    The characters 0 through 9 are for a custom mask. To use any of these characters as literals, put a backslash character (\) in front of the character. For example, to precede a phone number with a plus sign, a zero, and a dash:

    +\0-(###) ### - ####

    To set the displayed mask character, refer to MaskChar property.

    Example
    This example specifies the mask to use for the mask cell.
    FarPoint.Win.Spread.CellType.MaskCellType maskcell = new FarPoint.Win.Spread.CellType.MaskCellType();
    maskcell.Mask = "[ ULLLLLLL : ULLLLLLL ]";
    maskcell.MaskChar = Convert.ToChar("X"); 
    fpSpread1.ActiveSheet.Cells[0, 0].CellType = maskcell;
    Dim maskcell As New FarPoint.Win.Spread.CellType.MaskCellType()
    maskcell.Mask = "[ ULLLLLLL : ULLLLLLL ]"
    maskcell.MaskChar = "X"
    FpSpread1.ActiveSheet.Cells(0, 0).CellType = maskcell
    See Also