Spread for ASP.NET 10 Product Documentation > Developer's Guide > Customizing with Cell Types > Working with Editable Cell Types > Setting a Regular Expression Cell |
A regular expression cell is a cell that contains a text box that restricts the way data is entered in the cell to valid entries defined in a regular expression.
A default error message is displayed if the user types an invalid value and tries to leave the cell.
For details on the properties and methods for this cell type, refer to the RegExpCellType class.
The Regular Expression cell type expects the data in the cell to be a string. If you are working with other data types, such as date-time, then you need to get the date-time input, convert it to a string for the cell in the Format override, then convert the data back to a date-time in the Parse override.
For more information about creating regular expressions, refer to the following Microsoft web site topics:
To create a cell that restricts user input to match a regular expression, use this code.
C# |
Copy Code
|
---|---|
FarPoint.Web.Spread.RegExpCellType rgex = new FarPoint.Web.Spread.RegExpCellType(); rgex.ValidationExpression = "^\\d{3}-\\d{2}-\\d{4}$"; rgex.ErrorMessage = "SSN (ex, 123-45-6789)"; FpSpread1.ActiveSheetView.Cells[0, 0].CellType = rgex; |
VB |
Copy Code
|
---|---|
Dim rgex As New FarPoint.Web.Spread.RegExpCellType() rgex.ValidationExpression = "^\d{3}-\d{2}-\d{4}$" rgex.ErrorMessage = "SSN (ex, 123-45-6789)" FpSpread1.ActiveSheetView.Cells(0, 0).CellType = rgex |