Spread Windows Forms 12.0 Product Documentation
Using an Encoding Validator
Spread Windows Forms 12.0 Product Documentation > Developer's Guide > Customizing Interaction in Cells > Using Validation in Cells > Using an Encoding Validator

You can create a validator to determine whether a cell's value matches the specified encoding type.

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

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

The ThreeStateIconNotify class allows you to display an icon for a valid value, as shown in the following image.

Using Code

The following example displays a valid icon if you type an ASCII value or an invalid icon if you type a non-ASCII value.

CS
Copy Code
//Press Alt and type 0176 to enter a non-ASCII character in cell 1,1
FarPoint.Win.Spread.ThreeStateIconNotify three = new FarPoint.Win.Spread.ThreeStateIconNotify();
FarPoint.Win.Spread.EncodingValidator compare = new FarPoint.Win.Spread.EncodingValidator();
compare.Encoding = System.Text.Encoding.ASCII;
compare.Actions.Add(three);
fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), compare);
VB
Copy Code
'Press Alt and type 0176 to enter a non-ASCII character in cell 1,1
Dim three As New FarPoint.Win.Spread.ThreeStateIconNotify()
Dim compare As New FarPoint.Win.Spread.EncodingValidator()
compare.Encoding = System.Text.Encoding.ASCII
compare.Actions.Add(three)
fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), compare)