GrapeCity MultiRow Windows Forms Documentation
EncodingValidator

You can use the EncodingValidator class to validate whether a cell's value matches the specified encoding type. A validation error occurs if the cell's value contains characters that do not match the specified encoding type.

Using the Designer

Use the following instructions to validate a cell's value by comparison.

  1. Select a cell value to validate (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 left-top combo box and click the Add button.
  4. From the Members list, confirm that EncodingValidator has been selected.
  5. Select the Encoding property from the property grid and select Unicode.
  6. Select the Actions property from the property grid and click the ... button.
  7. Add LineNotify in the displayed CellValidateAction collection editor.
  8. Click the OK button to close the CellValidateAction collection editor.
  9. Click the OK button to close the CellValidator collection editor.
  10. Change the document window tab of the designer to Runtime.
  11. Enter a non-Unicode character, and check that the validation error occurs when you move to another cell.
  12. Delete the non-Unicode character, enter a Unicode character, and check that the validation error does not occur when you move to another cell.

Using Code

The following code illustrates the validation error when characters other than Unicode are entered in the cell.

[VB]

Imports GrapeCity.Win.MultiRow 
Dim textBoxCell1 As New TextBoxCell() 
Dim encodingValidator1 As New EncodingValidator()
encodingValidator1.Encoding = System.Text.Encoding.GetEncoding("Unicode") 
encodingValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(encodingValidator1) 
Dim cells As Cell() = {textBoxCell1} 
GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10

[CS]

using GrapeCity.Win.MultiRow; 
TextBoxCell textBoxCell1 = new TextBoxCell(); 
EncodingValidator encodingValidator1 = new EncodingValidator(); 
encodingValidator1.Encoding = System.Text.Encoding.GetEncoding("Unicode"); 
encodingValidator1.Actions.Add(new LineNotify()); 
textBoxCell1.Validators.Add(encodingValidator1); 
Cell[] cells = { textBoxCell1 }; 
gcMultiRow1.Template = Template.CreateGridTemplate(cells);
gcMultiRow1.RowCount = 10;
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options