GrapeCity MultiRow Windows Forms Documentation
CompareStringValidator

You can use the compare string validator to validate whether a cell's value matches the specified conditions. A validation error occurs if the value does not match the specified conditions.

Using the Designer

Complete the following steps to validate a cell's value by comparison.

  1. Select a cell for which you want to validate the value (for example, textBoxCell1).
  2. From the Properties window, select the Validators property and click the ... button.
  3. From the displayed CellValidator Collection editor, select CompareStringValidator from the top-left combo box and click the Add button.
  4. From the Members list, confirm that CompareStringValidator has been selected.
  5. Select the ComparedOperator property from the property grid and select Equals.
  6. Select the ComparedString property from the property grid and type AAA.
  7. Select the Actions property from the property grid and click the ... button.
  8. Add LineNotify in the displayed CellValidateAction collection editor.
  9. Click the OK button and close the CellValidateAction collection editor.
  10. Click the OK button and close the CellValidator collection editor.
  11. Change the document window tab of the designer to Runtime.
  12. Enter BBB and confirm that the validation error occurs when you move to another cell.
  13. Delete BBB, enter AAA, and confirm that the validation error does not occur when you move to another cell.

Using Code

The following code illustrates the validation error when a string other than "AAA" is entered in the cell. Blank text is also recognized as a validation error.

[VB]

Imports GrapeCity.Win.MultiRow 
Dim textBoxCell1 As New TextBoxCell() 
Dim compareStringValidator1 As New CompareStringValidator()
compareStringValidator1.ComparedOperator = CompareStringValidatorOperator.Equals 
compareStringValidator1.ComparedString = "AAA"
compareStringValidator1.Actions.Add(New LineNotify()) 
textBoxCell1.Validators.Add(compareStringValidator1) 
Dim cells As Cell() = {textBoxCell1}
GcMultiRow1.Template = Template.CreateGridTemplate(cells) 
GcMultiRow1.RowCount = 10

[CS]

using GrapeCity.Win.MultiRow;
TextBoxCell textBoxCell1 = new TextBoxCell(); 
CompareStringValidator compareStringValidator1 = new CompareStringValidator();
compareStringValidator1.ComparedOperator = CompareStringValidatorOperator.Equals; 
compareStringValidator1.ComparedString = "AAA";
compareStringValidator1.Actions.Add(new LineNotify()); 
textBoxCell1.Validators.Add(compareStringValidator1); 
Cell[] cells = { textBoxCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells); 
gcMultiRow1.RowCount = 10;
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options