MultiRow Windows Forms > Developer's Guide > Using MultiRow > User Input Validation > Built-in Cell Validators > CompareCellValidator |
You can use CompareCellValidator and validate a cell's value by comparing it to any other cell's value. CompareValueValidator can compare only DateTime, TimeSpan, and Decimal type (Numeric) values.
Complete the following steps to validate cell value by comparison. The example displays a validation error when values of two numericUpDown cells differ.
The following code illustrates the validation error when a cell's value and the value in an adjacent cell differ.
Imports GrapeCity.Win.MultiRow Dim numericUpDownCell1 As New NumericUpDownCell() numericUpDownCell1.Name = "numericUpDownCell1" numericUpDownCell1.Value = 12 Dim numericUpDownCell2 As New NumericUpDownCell() numericUpDownCell2.Name = "numericUpDownCell2" numericUpDownCell2.Value = 12 Dim compareCellValidator1 As New CompareCellValidator() compareCellValidator1.RequiredType = GetType(Integer) compareCellValidator1.ComparedCellName = "numericUpDownCell2" compareCellValidator1.ComparedOperator = ValidateComparisonOperator.Equals compareCellValidator1.Actions.Add(New LineNotify()) numericUpDownCell1.Validators.Add(compareCellValidator1) Dim cells As Cell() = {numericUpDownCell1, numericUpDownCell2} GcMultiRow1.Template = Template.CreateGridTemplate(cells) GcMultiRow1.RowCount = 10 |
using GrapeCity.Win.MultiRow; NumericUpDownCell numericUpDownCell1 = new NumericUpDownCell(); numericUpDownCell1.Name = "numericUpDownCell1"; numericUpDownCell1.Value = 12; NumericUpDownCell numericUpDownCell2 = new NumericUpDownCell(); numericUpDownCell2.Name = "numericUpDownCell2"; numericUpDownCell2.Value = 12; CompareCellValidator compareCellValidator1 = new CompareCellValidator(); compareCellValidator1.RequiredType = typeof(int); compareCellValidator1.ComparedCellName = "numericUpDownCell2"; compareCellValidator1.ComparedOperator = ValidateComparisonOperator.Equals; compareCellValidator1.Actions.Add(new LineNotify()); numericUpDownCell1.Validators.Add(compareCellValidator1); Cell[] cells = { numericUpDownCell1, numericUpDownCell2 }; gcMultiRow1.Template = Template.CreateGridTemplate(cells); gcMultiRow1.RowCount = 10; |