GrapeCity MultiRow Windows Forms Documentation
PairCharValidator

You can use PairCharValidator and validate if the pair characters included in the cell value match each other. For example, you can validate if you have forgotten to put a closing bracket.

Using Designer

Complete the following steps to validate pair characters. The example displays a validation error when any bracket does not have its corresponding pair.

  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 PairCharValidator from the top-left combo box and click the Add button.
  4. From the Members list, confirm that PairCharValidator has been selected.
  5. Select the PairChars property from the property grid and click the ... button.
  6. Add PairChar in the displayed PairChar collection editor.
  7. In the added PairChar, set the Left property to ( and the Right property to ) .
  8. Click the OK button and close the PairChar collection editor.
  9. Select the Actions property from the property grid and click the ... button.
  10. Add LineNotify in the displayed CellValidateAction collection editor.
  11. Click the OK button and close the CellValidateAction collection editor.
  12. Click the OK button and close the CellValidator collection editor.
  13. Change the document window tab of the designer to Runtime.
  14. Enter ((1+2)*3 in textBoxCell1 to confirm that the validation error occurs.

Using Code

The following code displays a validation error when text entered in a cell does not have the corresponding bracket.

[VB]

Imports GrapeCity.Win.MultiRow

Dim textBoxCell1 As New TextBoxCell()
Dim pairCharValidator1 As New PairCharValidator()
Dim parChar1 As New PairChar("(", ")")
pairCharValidator1.PairChars.Add(parChar1)
pairCharValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(pairCharValidator1)

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

[CS]

using GrapeCity.Win.MultiRow;

TextBoxCell textBoxCell1 = new TextBoxCell();
PairCharValidator pairCharValidator = new PairCharValidator();
PairChar pairChar1 = new PairChar('(', ')');
pairCharValidator.PairChars.Add(pairChar1);
pairCharValidator.Actions.Add(new LineNotify());
textBoxCell1.Validators.Add(pairCharValidator);

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

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options