Spread Windows Forms 10.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Editable Cell Types > Setting a Regular Expression Cell |
You can create a regular expression cell that restricts the data entered in the cell to valid entries defined in a regular expression. The data is evaluated when exiting the cell. Invalid data is removed and the EditError event is raised.
You use the RegularExpressionCellType class to set the regular expression cell and its properties.
For a summary of regular expression syntax, refer to the Regular Expression Syntax topic in the Microsoft NET Framework Reference. For an introduction to regular expressions, refer to the Introduction to Regular Expressions topic in the Microsoft .NET Framework Reference.
This example creates a regular expression cell.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.RegularExpressionCellType regexcell = new FarPoint.Win.Spread.CellType.RegularExpressionCellType() regexcell.RegularExpression = "[0-9]{3}-[0-9]{2}-[0-9]{4}"; fpSpread1.ActiveSheet.Cells[0, 0].CellType = regexcell; |
VB |
Copy Code
|
---|---|
Dim regexcell As New FarPoint.Win.Spread.CellType.RegularExpressionCellType() regexcell.RegularExpression = "[0-9]{3}-[0-9]{2}-[0-9]{4}" FpSpread1.ActiveSheet.Cells(0, 0).CellType = regexcell |
Or right-click on the cell or cells and select Cell Type. From the list, select RegularExpression. In the CellType editor, set the properties you need. Click Apply.