[]
        
(Showing Draft Content)

Using a Pair Validator

You can create a validator that requires matching characters. This can be useful if you enter text that requires matching brackets.

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 PairCharValidator 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 a cell with an invalid backcolor.

Pair Validator

Using Code

The following example requires matching parentheses to be valid.

//The error backcolor is displayed if the text contains a single, non-matching parenthesis
FarPoint.Win.Spread.CellStyleNotify cnotify = new FarPoint.Win.Spread.CellStyleNotify();
cnotify.InvalidCellStyle.BackColor = Color.Yellow;
FarPoint.Win.Spread.PairChar pair = new FarPoint.Win.Spread.PairChar();
pair.Left = '(';
pair.Right = ')';
FarPoint.Win.Spread.PairCharValidator pairvalid = new FarPoint.Win.Spread.PairCharValidator();
pairvalid.PairChars.Add(pair);
pairvalid.Actions.Add(cnotify);
fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), pairvalid);
'The error backcolor is displayed if the text contains a single, non-matching parenthesis
Dim cnotify As New FarPoint.Win.Spread.CellStyleNotify()
cnotify.InvalidCellStyle.BackColor = Color.Yellow
Dim pair As New FarPoint.Win.Spread.PairChar()
pair.Left = "("
pair.Right = ")"
Dim pairvalid As New FarPoint.Win.Spread.PairCharValidator()
pairvalid.PairChars.Add(pair)
pairvalid.Actions.Add(cnotify)
fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), pairvalid)

See Also

Using a Cell Comparison Validator

Using a Character Format 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 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