Spread Windows Forms 8.0 Product Documentation
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.

Using the Properties Window

  1. At design time, in the Properties window, select the Spread component.
  2. Select the Sheets property.
  3. Click the button to display the SheetView Collection Editor.
  4. In the Members list, select the sheet in which the cells appear.
  5. In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
  6. Select the cells for which you want to set the cell type.
  7. In the property list, select the CellType property and choose the Mask cell type.
  8. Expand the list of properties under the CellType property. Select and set these specific properties as needed.
  9. Click OK to close the Cell, Column, and Row Editor.
  10. Click OK to close the SheetView Collection Editor.

Using Code

  1. Define the mask cell by creating an instance of the MaskCellType class.
  2. Define the mask, including literals and placeholders by setting the Mask property.
  3. Assign the mask cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the MaskCellType object.

Example

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

Using the Spread Designer

  1. Select the cell or cells in the work area.
  2. In the property list, in the Misc category, select CellType. From the drop-down list, choose the Mask cell type. Now expand the CellType property and various properties are available that are specific to this cell type. Select and set those properties as needed.

    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.

  3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback