Spread Windows Forms 10.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Editable Cell Types > Setting a Mask Cell |
You can use a mask cell for masking characters to limit user entry. You specify which subsets of characters are allowed for each item in the mask. You can define how the mask appears, with literals displayed exactly as typed and placeholders showing the places for user entry. To create a mask, set the Mask property to a string of mask characters. Each mask character represents a position in which the user can type a character.
You use the MaskCellType class to set the mask cell and its properties.
For a detailed list of the mask characters, refer to the Mask property in the MaskCellType class. For a description of how to set the placeholder character, refer to the MaskChar property.
This example sets a cell to be a mask cell and restricts the user to entering two alphabetic names and prompts them with X’s. The display looks like this:
-> XXXXXXXX : XXXXXXXX <-
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.MaskCellType maskcell = new FarPoint.Win.Spread.CellType.MaskCellType(); maskcell.Mask = "-> ULLLLLLL : ULLLLLLL <-"; maskcell.MaskChar = Convert.ToChar("X"); fpSpread1.ActiveSheet.Cells[1, 1].CellType = maskcell; |
VB |
Copy Code
|
---|---|
Dim maskcell As New FarPoint.Win.Spread.CellType.MaskCellType() maskcell.Mask = "-> ULLLLLLL : ULLLLLLL <-" maskcell.MaskChar = "X" FpSpread1.ActiveSheet.Cells(1, 1).CellType = maskcell |
Or right-click on the cell or cells and select Cell Type. From the list, select Mask. In the CellType editor, set the properties you need. Click Apply.