# Using the Exclude List Validator

Learn how to use the Exclude List Validator in Spread.NET to create a validator with a list of invalid values and take specific actions when an error occurs.

## Content

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](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.CellStyleNotify.html). Then use the [AddValidators](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.AddValidators.html) method to add the validator to a cell range.
The following image displays a cell with an invalid value.
![Exclude List Validator](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/excludelist.png)

## Using Code

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

```csharp
//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);
```

```vbnet
'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)
```

## See Also

[Using a Cell Comparison Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellcomparevalidator)
[Using a Character Format Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellcharformatv)
[Using a String Comparison Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellcomparestring)
[Using a Value Comparison Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellcomparevalue)
[Using an Encoding Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellencodingvalid)
[Using the Include List Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellincludevalidate)
[Using a Pair Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellpairvalidate)
[Using the Range Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellrangevalidator)
[Using a Regular Expression Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellregexpression)
[Using a Required Field Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellrequiredvalid)
[Using a Required Type Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellrequiretypev)
[Using a Surrogate Character Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-cellsurrogate)
[Using a Text Length Validator](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid/spwin-cellvalidation/spwin-celltextlvalid)