GrapeCity MultiRow Windows Forms Documentation
ValueProcess

You can use the ValueProcess class to perform the processes of retaining, deleting, or restoring the previous value when a validation error occurs. ValueProcess is executed when the cell validation or cell editing state ends.

Using the Designer

Use the following steps to use the value process for cell validation.

  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 IncludeListValidator from the left-top combo box and click the Add button.
  4. From the Members list, confirm that IncludeListValidator has been selected.
  5. Select the Candidates property from the property grid and click the ... button.
  6. Set the required string in the displayed String Collection Editor.
    For example:
    • New York
    • California
  7. Click the OK button to close the window.
  8. Select the Actions property from the property grid and click the ... button.
  9. Add ValueProcess in the displayed CellValidateAction collection editor.
  10. From the Members list, confirm that ValueProcess has been selected. In the property grid, set the DoActionReason property to CellValidating, and ValueProcessOption property to Clear.
  11. Click the OK button to close the CellValidateAction collection editor.
  12. Click the OK button to close the CellValidator collection editor.
  13. Change the document window tab of the designer to Runtime.
  14. Enter Washington in textBoxCell1 to confirm that the validation error occurs and the entered value gets deleted, when you move to another cell.

Using Code

The following code illustrates the validation error, and deletes the entered value when a string other than "New York" or "California" is entered in the cell.

[VB]

Imports GrapeCity.Win.MultiRow 
Dim textBoxCell1 As New TextBoxCell() 
Dim includeListValidator1 As New IncludeListValidator() 
Dim valueProcess1 As New ValueProcess() 
valueProcess1.DoActionReason = ValidateReasons.CellValidating 
valueProcess1.ValueProcessOption = ValueProcessOption.Clear
includeListValidator1.Candidates = New String() {"New York", "California"} 
includeListValidator1.Actions.Add(valueProcess1)
textBoxCell1.Validators.Add(includeListValidator1) 
Dim cells As Cell() = {textBoxCell1} 
GcMultiRow1.Template = Template.CreateGridTemplate(cells)
GcMultiRow1.RowCount = 10

[CS]

using GrapeCity.Win.MultiRow; 
TextBoxCell textBoxCell1 = new TextBoxCell(); 
IncludeListValidator includeListValidator1 = new IncludeListValidator(); 
ValueProcess valueProcess1 = new ValueProcess(); 
valueProcess1.DoActionReason = ValidateReasons.CellValidating; 
valueProcess1.ValueProcessOption = ValueProcessOption.Clear; 
includeListValidator1.Candidates = new string[] { "New York", "California" }; 
includeListValidator1.Actions.Add(valueProcess1); 
textBoxCell1.Validators.Add(includeListValidator1); 
Cell[] cells = { textBoxCell1 };
gcMultiRow1.Template = Template.CreateGridTemplate(cells); 
gcMultiRow1.RowCount = 10;
If the DoActionReason property is set to EndEdit, then only the timing at which the value process is executed differs from when it is set to CellValidating, but the end result is the same.
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options