GrapeCity MultiRow Windows Forms Documentation
ExcludeListValidator

You can use ExcludeListValidator and validate whether the cell's value matches the specified list of values. A validation error occurs if the value matches any of the values in the list.

Using Designer

Complete the following steps to set ExcludeListValidator. In the example, a validation error occurs if the text Air Mail or Sea Mail has been entered in the cell. Blank characters are not recognized as a validation error.

  1. Select a cell whose value needs to be validated (for example, textBoxCell1).
  2. From the Properties window, select the Validators property and click the ... button.
  3. From the displayed CellValidator collection editor, select ExcludeListValidator from the top-left combo box and click the Add button.
  4. From the Members list, confirm that ExcludeListValidator has been selected.
  5. Select the Candidates property from the property grid and click the ... button.
  6. In the displayed TextCollection editor, set the strings to be excluded, in this example:
    • Air Mail
    • Sea Mail
  7. Click the OK button and close the window.
  8. Select the Actions property from the property grid and click the ... button.
  9. Add LineNotify in the CellValidateAction collection editor.
  10. Click the OK button and close the CellValidateAction collection editor.
  11. Click the OK button and close the CellValidator collection editor.
  12. Change the document window tab of the designer to Runtime.
  13. Type Air Mail, move the focus from the cell, and confirm that the validation error occurs.
  14. Remove Air Mail, type Economy Air Mail, and move the focus from the cell to confirm that the validation error does not occur.

Using Code

The following code displays a validation error when the specified text Air Mail and Sea Mail has been entered in the cell. Blank characters are not recognized as a validation error.

[VB]

Imports GrapeCity.Win.MultiRow

Dim textBoxCell1 As New TextBoxCell()
Dim excludeListValidator1 As New ExcludeListValidator()
excludeListValidator1.Candidates = New String() {"Air Mail", "Sea Mail"}
excludeListValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(excludeListValidator1)

Dim cells As Cell() = {textBoxCell1}
GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10

[CS]

using GrapeCity.Win.MultiRow;

TextBoxCell textBoxCell1 = new TextBoxCell();
ExcludeListValidator excludeListValidator1 = new ExcludeListValidator();
excludeListValidator1.Candidates = new string[] { "Air Mail", "Sea Mail" };
excludeListValidator1.Actions.Add(new LineNotify());
textBoxCell1.Validators.Add(excludeListValidator1);

Cell[] cells = { textBoxCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells);
gcMultiRow1.RowCount = 10;
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options