MultiRow Windows Forms > Developer's Guide > Using MultiRow > User Input Validation > Built-in Cell Validators > TextLengthValidator |
You can use the TextLengthValidator class to validate whether the height of a cell's value falls within the specified range. A validation error occurs if the height of the value does not fall within the specified range.
Use the following instructions to validate the height of a cell's value.
The following code illustrates the validation error when a string of more than 5 bytes is entered in the cell.
Imports GrapeCity.Win.MultiRow Dim textBoxCell1 As New TextBoxCell() Dim textLengthValidator1 As New TextLengthValidator() textLengthValidator1.Encoding = System.Text.Encoding.GetEncoding("Unicode") textLengthValidator1.LengthUnit = LengthUnit.Byte textLengthValidator1.MaximumLength = 5 textLengthValidator1.Actions.Add(New LineNotify()) textBoxCell1.Validators.Add(textLengthValidator1) Dim cells As Cell() = {textBoxCell1} GcMultiRow1.Template = Template.CreateGridTemplate(cells) GcMultiRow1.RowCount = 10 |
using GrapeCity.Win.MultiRow; TextBoxCell textBoxCell1 = new TextBoxCell(); TextLengthValidator textLengthValidator1 = new TextLengthValidator(); textLengthValidator1.Encoding = System.Text.Encoding.GetEncoding("Unicode"); textLengthValidator1.LengthUnit = LengthUnit.Byte; textLengthValidator1.MaximumLength = 5; textLengthValidator1.Actions.Add(new LineNotify()); textBoxCell1.Validators.Add(textLengthValidator1); Cell[] cells = { textBoxCell1 }; gcMultiRow1.Template = Template.CreateGridTemplate(cells); gcMultiRow1.RowCount = 10; |