Spread Windows Forms 12.0 Product Documentation
Using the Exclude List Validator
Spread Windows Forms 12.0 Product Documentation > Developer's Guide > Customizing Interaction in Cells > Using Validation in Cells > Using the Exclude List Validator

You can create a validator that has a list of invalid values. An error occurs if the user types a value from the candidate list.

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 ExcludeListValidator 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 value.

Using Code

The following example displays an invalid backcolor if you type an item from the list.

CS
Copy Code
//Type one of the candidate items in cell 1,1 to see the error notification
FarPoint.Win.Spread.CellStyleNotify cnotify = new FarPoint.Win.Spread.CellStyleNotify();
cnotify.InvalidCellStyle.BackColor = Color.Bisque;
FarPoint.Win.Spread.ExcludeListValidator excludelist = new FarPoint.Win.Spread.ExcludeListValidator();
excludelist.Candidates = new string[] { "Bird", "Deer", "Squirrel", "Lizard" };
excludelist.Actions.Add(cnotify);
fpSpread1.Sheets[0].AddValidators(new FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), excludelist);
VB
Copy Code
'Type one of the candidate items in cell 1,1 to see the error notification
Dim cnotify As New FarPoint.Win.Spread.CellStyleNotify()
cnotify.InvalidCellStyle.BackColor = Color.Bisque
Dim excludelist As New FarPoint.Win.Spread.ExcludeListValidator()
excludelist.Candidates = New String() {"Bird", "Deer", "Squirrel", "Lizard"}
excludelist.Actions.Add(cnotify)
fpSpread1.Sheets(0).AddValidators(New FarPoint.Win.Spread.Model.CellRange(1, 1, 1, 1), excludelist)