| MultiRow Windows Forms > Developer's Guide > Using MultiRow > User Input Validation > Built-in Cell Validators > CompareValueValidator |
You can use CompareValueValidator and validate a cell's value by comparing it to any other value. CompareValueValidator can compare only DateTime, TimeSpan, and Decimal type (Numeric) values.
Complete the following instructions to validate a cell's value by comparison. The example displays a validation error when the value entered in numericUpDown cell is greater than 5.
The following code illustrates the validation error when a value entered in a cell is greater than 100.
Imports GrapeCity.Win.MultiRow
Dim textBoxCell1 As New TextBoxCell()
Dim compareValueValidator1 As New CompareValueValidator()
compareValueValidator1.RequiredType = GetType(Integer)
compareValueValidator1.ComparedValue = 100
compareValueValidator1.ComparedOperator = ValidateComparisonOperator.LessThanOrEquals
compareValueValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(compareValueValidator1)
Dim cells As Cell() = {textBoxCell1}
GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10
|
using GrapeCity.Win.MultiRow;
TextBoxCell textBoxCell1 = new TextBoxCell();
CompareValueValidator compareValueValidator1 = new CompareValueValidator();
compareValueValidator1.RequiredType = typeof(int);
compareValueValidator1.ComparedValue = 100;
compareValueValidator1.ComparedOperator = ValidateComparisonOperator.LessThanOrEquals;
compareValueValidator1.Actions.Add(new LineNotify());
textBoxCell1.Validators.Add(compareValueValidator1);
Cell[] cells = { textBoxCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells);
gcMultiRow1.RowCount = 10;
|