You can use the ThreeStateIconNotify class to notify the user of an error by displaying an icon when the input value is valid and when it is invalid. In addition, the icon is not shown if nothing is entered.
Using the Designer
Use the following steps to use three-state notification for cell validation.
- Select a cell value to validate (for example, numericUpDownCell1).
- From the Properties window, select the Validators property and click the ... button.
- From the CellValidator collection editor, select RangeValidator from the left-top combo box and click the Add button.
- From the Members list, confirm that RangeValidator has been selected.
- Select the MaxValue property from the property grid and type 10.
- Select the MinValue property from the property grid and type 0.
- Click the OK button and close the window.
- Select the Actions property from the property grid and click the ... button.
- Add ThreeStateIconNotify in the CellValidateAction collection editor.
- From the Members list, confirm that ThreeStateIconNotify has been selected. Set the DoActionReason property in the property grid to EndEdit.
- Click the OK button to close the CellValidateAction collection editor.
- Click the OK button to close the CellValidator collection editor.
- Change the document window tab of the designer to Runtime.
- Enter 20 in the numericUpDownCell1 and check that the error icon is displayed when you move to another cell.
- Enter 5 in the numericUpDownCell1 and check that the icon for the valid value is displayed when you move to another cell.
Using Code
The following code displays the error icon when a value outside the range of 0 to 10 is entered in the cell, and displays the icon for a valid value when a value within the range of 0 to 10 is entered.
[VB]
Imports GrapeCity.Win.MultiRow
Dim numericUpDownCell1 As New NumericUpDownCell()
Dim rangeValidator1 As New RangeValidator()
rangeValidator1.RequiredType = GetType(Integer)
rangeValidator1.MaxValue = 10
rangeValidator1.MinValue = 0
rangeValidator1.Actions.Add(New ThreeStateIconNotify())
numericUpDownCell1.Validators.Add(rangeValidator1)
Dim cells As Cell() = {numericUpDownCell1} GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10
|
[CS]
using GrapeCity.Win.MultiRow;
NumericUpDownCell numericUpDownCell1 = new NumericUpDownCell();
RangeValidator rangeValidator1 = new RangeValidator();
rangeValidator1.RequiredType = typeof(int);
rangeValidator1.MaxValue = 10;
rangeValidator1.MinValue = 0;
rangeValidator1.Actions.Add(new ThreeStateIconNotify());
numericUpDownCell1.Validators.Add(rangeValidator1);
Cell[] cells = { numericUpDownCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells);
gcMultiRow1.RowCount = 10;
|
|
The BlinkRate, BlinkStyle, and IconPadding properties that are available in the ThreeStateIconNotify property of InputMan are not supported. |
See Also