GrapeCity MultiRow Windows Forms Documentation
FocusProcess Class
Members  Example 


Represents a special CellValidateAction that keeps the focus on the validating Cell when validation fails.
Syntax
<ToolboxBitmapAttribute()>
<DefaultPropertyAttribute("PreventFocusLeave ")>
Public Class FocusProcess 
   Inherits CellValidateAction
   Implements INamedObject 
Dim instance As FocusProcess
[ToolboxBitmap()]
[DefaultProperty("PreventFocusLeave ")]
public class FocusProcess : CellValidateAction, INamedObject  
Remarks

This action is similar to setting cancel to true in the GcMultiRow.CellValidating event. If you change the DoActionReason, the behavior of this action is special. For example, if you add ValidateReasons.EndEdit and ValidateReasons.CancelEdit, the validating cell cannot end edit mode even if you do not leave the current cell.

This action only takes effect when setting the PreventFocusLeave property value to true.

Example
The following code example uses the RegularExpressionValidator to validate whether the input value matches RegularExpressionValidator.Expression, which indicates a currency value. When you input '-!2.05' in the Cell, then move the current cell to another Row, the focus cannot leave, because the input value does not match the RegularExpressionValidator.Expression. The FocusProcess occurs. If you input '-12.05', this matches. This example is part of a larger example available for the CellValidator class.
void setRegularExpressionValidator_Click(object sender, EventArgs e)
        {
            Template template = Template.CreateGridTemplate(1);

            RegularExpressionValidator regularExpressionValidator = new RegularExpressionValidator();
            //Define a regular expression for currency values.
            regularExpressionValidator.Expression = @"^-?\d+(\.\d{2})?$";
            regularExpressionValidator.RegexOptions = System.Text.RegularExpressions.RegexOptions.CultureInvariant;

            FocusProcess focusProcess = new FocusProcess();
            focusProcess.PreventFocusLeave = true;
            //When CurrentCell moves to another Row, the action is done.
            focusProcess.DoActionReason = ValidateReasons.RowValidating;

            regularExpressionValidator.Actions.Add(focusProcess);

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

            this.gcMultiRow1.Template = template;
            label .Text = @"The RegularExpressionValidator.Expression is '^-?\d+(\.\d{2})?$', which expresses a currency 
value, input '-!2.05', then move CurrentCell to another Row to trigger validation (DoActionReasion is RowValidating), the 
focus cannot move, input '-12.05', the focus moves to another Row.";
        }
Private Sub setRegularExpressionValidator_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
setRegularExpressionValidator.Click
        Dim template As Template = template.CreateGridTemplate(1)

        Dim regularExpressionValidator As New RegularExpressionValidator()
        'Define a regular expression for currency values.
        regularExpressionValidator.Expression = "^-?\d+(\.\d{2})?$"
        regularExpressionValidator.RegexOptions = System.Text.RegularExpressions.RegexOptions.CultureInvariant

        Dim focusProcess As New FocusProcess()
        focusProcess.PreventFocusLeave = True
        'When CurrentCell moves to another Row, the action is done.
        focusProcess.DoActionReason = ValidateReasons.RowValidating

        regularExpressionValidator.Actions.Add(focusProcess)

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

        Me.gcMultiRow1.Template = template
        label.Text = "The RegularExpressionValidator.Expression is '^-?\d+(\.\d{2})?$', which expresses a currency value, 
input '-!2.05', then move CurrentCell to another Row to trigger validation (DoActionReasion is RowValidating), the focus 
cannot move, input '-12.05', the focus moves to another Row."
    End Sub
Inheritance Hierarchy

System.Object
   GrapeCity.Win.MultiRow.CellValidateAction
      GrapeCity.Win.MultiRow.FocusProcess

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

FocusProcess Members
GrapeCity.Win.MultiRow Namespace
CellValidateAction Class

 

 


Copyright © GrapeCity, inc. All rights reserved.