GrapeCity MultiRow Windows Forms Documentation
ValidateReasons Enumeration
Example Example 


Specifies the reasons that cause a CellValidateAction to execute.
Syntax
<EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.Design.FlagEnumEditor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<FlagsAttribute()>
Public Enum ValidateReasons 
   Inherits System.Enum
Dim instance As ValidateReasons
[Editor(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.Design.FlagEnumEditor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[Flags()]
public enum ValidateReasons : System.Enum 
Members
MemberDescription
CancelEditIndicates the CellValidateAction that is executed when a cell leaves edit mode without applying the edited value.
CancelRowIndicates the CellValidateAction that is executed when the user presses Esc to cancel the entire row's edited value.
CellValidatingIndicates the CellValidateAction that is executed when the cell validates.
EditedFormattedValueChangedIndicates the CellValidateAction that is executed when the user changes the editing control's or editing cell's value.
EndEditIndicates the CellValidateAction that is executed when a cell leaves edit mode and applies the edited value.
RowValidatingIndicates the CellValidateAction that is executed when the row validates.
Example
The following code example uses the RangeValidator to validate whether the committed value is between MinValue and MaxValue. If you enter edit mode and input 49 (not in range), then press the Enter key to end the edit, a red underline paints to show you the validation failed. If you input 55 (in range), then press the Enter key, no underline paints since the validation succeeds. This example sets the CellValidateAction.DoActionReason to EndEdit, which indicates the CellValidateAction is done when you execute the end edit operation, similar to pressing the Enter key. This example is part of a larger example available in the CellValidator class example.
void setRangeValidator_Click(object sender, EventArgs e)
        {
            Template template = Template.CreateGridTemplate(1);

            //Create one RangeValidator to validate whether the committed value is between one range.
            RangeValidator rangValidator = new RangeValidator();
            //Set the RequiredType first, then set other Properties.
            rangValidator.RequiredType = typeof(int);
            rangValidator.MinValue = 5;
            rangValidator.MaxValue = 10;
            rangValidator.NullIsValid = false;

            LineNotify lineNotifyAction = new LineNotify();
            //When you end edit mode, the action is done (press Enter key)
            lineNotifyAction.DoActionReason = ValidateReasons.EndEdit;
            lineNotifyAction.LineColor = Color.Red;

            rangValidator.Actions.Add(lineNotifyAction);

            template.Row.Cells[0].Validators.Add(rangValidator);

            this.gcMultiRow1.Template = template;
            label.Text = "The RangeValidator's MinValue is 5, MaxValue is 10, input 4 (not in the range) in one cell, press 
Enter key to trigger validation (DoActionReason is EndEdit), a red underline is shown.";
        }
Private Sub setRangeValidator_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
setRangeValidator.Click
        Dim template As Template = template.CreateGridTemplate(1)

        'Create one RangeValidator to validate whether the committed value is in range.
        Dim rangValidator As New RangeValidator()
        'Set the RequiredType first, then set other Properties.
        rangValidator.RequiredType = GetType(Integer)
        rangValidator.MinValue = 5
        rangValidator.MaxValue = 10
        rangValidator.NullIsValid = False

        Dim lineNotifyAction As New LineNotify()
        'When you end edit mode, the action is done (press Enter key)
        lineNotifyAction.DoActionReason = ValidateReasons.EndEdit
        lineNotifyAction.LineColor = Color.Red

        rangValidator.Actions.Add(lineNotifyAction)

        template.Row.Cells(0).Validators.Add(rangValidator)

        Me.gcMultiRow1.Template = template
        label.Text = "The RangeValidator's MinValue is 5, MaxValue is 10, input 4 (not in range) in one cell, press Enter 
key to trigger validation (DoActionReason is EndEdit), a red underline is shown."
    End Sub
Inheritance Hierarchy

System.Object
   System.ValueType
      System.Enum
         GrapeCity.Win.MultiRow.ValidateReasons

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GrapeCity.Win.MultiRow Namespace
CellValidateAction Class

 

 


Copyright © GrapeCity, inc. All rights reserved.