[]
        
(Showing Draft Content)

Using a Character Format Validator

You can create a validator that checks for specific characters.

A validation error occurs if the value is not valid. You can also create an action, such as adding a backcolor to the cell, that lets the user know the value is invalid.

Use the CharFormatValidator class to create the validator. Specify a notification type such as CellStyleNotify. Then use the AddValidators method to add the validator to a cell range.

The following image displays an invalid backcolor for the cell.

Spread WinForms screenshot illustrating Character Format Validator in a spreadsheet control, with the visible cells and interface state documenting the developer workflow.

Using Code

The following example displays an invalid backcolor if you type characters other than the format string.

FarPoint.Win.Spread.CellStyleNotify cnotify = new FarPoint.Win.Spread.CellStyleNotify();
cnotify.InvalidCellStyle.BackColor = Color.Aqua;
FarPoint.Win.Spread.CharFormatValidator cFormatValidator1 = new FarPoint.Win.Spread.CharFormatValidator();
cFormatValidator1.Format = "Aa";
cFormatValidator1.Actions.Add(cnotify);
fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), cFormatValidator1);
Dim cnotify As New FarPoint.Win.Spread.CellStyleNotify()
cnotify.InvalidCellStyle.BackColor = Color.Aqua
Dim charFormatValidator1 As New FarPoint.Win.Spread.CharFormatValidator()
charFormatValidator1.Format = "Aa"
charFormatValidator1.Actions.Add(cnotify)
fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), charFormatValidator1)

See Also

Using a Cell Comparison Validator

Using a String Comparison Validator

Using a Value Comparison Validator

Using an Encoding Validator

Using the Exclude List Validator

Using the Include List Validator

Using a Pair Validator

Using the Range Validator

Using a Regular Expression Validator

Using a Required Field Validator

Using a Required Type Validator

Using a Surrogate Character Validator

Using a Text Length Validator