[]
        
(Showing Draft Content)

Using the Range Validator

You can use the range validator to check to see if a value is within a specified range. A validation error occurs if the value is not within the specified range. You can also create an action, such as changing the cell backcolor, that lets the user know the value is invalid.

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

The following image uses the CellStyleNotify class to change the cell backcolor when an invalid value is typed.

Range Validator Example

Using Code

The following example sets a minimum and maximum value for the cell. A different backcolor is shown if you type an invalid value in the cell.

FarPoint.Win.Spread.CellStyleNotify stylenotify = new FarPoint.Win.Spread.CellStyleNotify();
stylenotify.InvalidCellStyle.BackColor = Color.Aquamarine;
FarPoint.Win.Spread.RangeValidator rvalid = new FarPoint.Win.Spread.RangeValidator();
rvalid.MaxValue = 10;
rvalid.MinValue = 0;
rvalid.Actions.Add(stylenotify);
fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), rvalid);
Dim stylenotify As New FarPoint.Win.Spread.CellStyleNotify()
stylenotify.InvalidCellStyle.BackColor = Color.Aquamarine
Dim rvalid As New FarPoint.Win.Spread.RangeValidator()
rvalid.MaxValue = 10
rvalid.MinValue = 0
rvalid.Actions.Add(stylenotify)
fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), rvalid)

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 a Pair 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