GrapeCity MultiRow Windows Forms Documentation
IncludeListValidator

You can use IncludeListValidator and validate if a cell's value is one of the values in the specified list. A validation error occurs if the value does not match any of the values in the list.

Using Designer

Complete the following steps to set a list of values. The following example uses a TextBoxCell1 for which a validation error occurs if a string other than Tokyo or Osaka has been entered. Blank characters are recognized as validation errors.

  1. Select a cell whose values 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 IncludeListValidator from the combo box on the top-left and click the Add button.
  4. From the Members list, confirm that IncludeListValidator has been selected.
  5. Select the Candidates property from the property grid and click the ... button.
  6. In the displayed TextCollection editor, set the required text, in this example:
    • Tokyo
    • Osaka
  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 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 Kyoto, move the focus from the cell, and confirm the occurrence of the validation error.
  14. Remove Kyoto and type Osaka, move the focus from the cell, and confirm that the validation error does not occur.

Using Code

The following code displays a validation error when text other than Tokyo or Osaka is entered. The blank character is also recognized as a validation error.

[VB]

Imports GrapeCity.Win.MultiRow

Dim textBoxCell1 As New TextBoxCell()
Dim includeListValidator1 As New IncludeListValidator()
includeListValidator1.Candidates = New String() {"Tokyo", "Osaka"}
includeListValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(includeListValidator1)

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

[CS]

using GrapeCity.Win.MultiRow;

TextBoxCell textBoxCell1 = new TextBoxCell();
IncludeListValidator includeListValidator1 = new IncludeListValidator();
includeListValidator1.Candidates = new string[] { "Tokyo", "Osaka" };
includeListValidator1.Actions.Add(new LineNotify());
textBoxCell1.Validators.Add(includeListValidator1);

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

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options