GrapeCity MultiRow Windows Forms Documentation
PairCharValidator Class
Members  Example 


Represents a special CellValidator that validates whether the specifed value matches the given PairChars.
Object Model
PairCharValidator ClassValidateActionCollection ClassCellValidateAction Class
Syntax
<ToolboxBitmapAttribute()>
Public Class PairCharValidator 
   Inherits CellValidator
   Implements INamedObject 
Dim instance As PairCharValidator
[ToolboxBitmap()]
public class PairCharValidator : CellValidator, INamedObject  
Remarks
This CellValidator validates whether the value's string representation matches one or more character pairs. You can add a PairChar to PairChars. For example, the validated value's string representation is "10 * (5 + 2)". One of the PairChars is "( )". Because the validated value has a "(" and another ")" that matches the "(", the result is successful. If the validated value's string representation is "10 * (5 + 2", the result is a failure.
Example
The following code example uses the PairCharValidator to validate whether the input string matches the char pair '( )'. If you enter edit mode and input 2*(3+4, the right ')' does not match the left '(', and the input text font changes to a bold red color to notify you the validation failed. This example is part of a larger example available for the CellValidator class.
void setPairCharValidator_Click(object sender, EventArgs e)
        {
            Template template = Template.CreateGridTemplate(1);

            PairCharValidator pairCharValidator = new PairCharValidator();
            pairCharValidator.PairChars.Add(new PairChar('(', ')'));

            CellStyleNotify cellStyleNotify = new CellStyleNotify();
            cellStyleNotify.InvalidCellStyle.ForeColor = Color.Red;
            cellStyleNotify.InvalidCellStyle.Font = new Font(DefaultFont, FontStyle.Bold);
            cellStyleNotify.DoActionReason = ValidateReasons.EditedFormattedValueChanged;

            pairCharValidator.Actions.Add(cellStyleNotify);

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

            this.gcMultiRow1.Template = template;
            label.Text = "The PairCharValidator.PairChars is '( )', in edit mode, if you input '2*(3+4' to trigger validation, 
validation fails, the font changes, if input '2*(3+4)' to trigger validation, the validation succeeds.";
        }
Private Sub setPairCharValidator_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
setPairCharValidator.Click
        Dim template As Template = template.CreateGridTemplate(1)

        Dim pairCharValidator As New PairCharValidator()
        pairCharValidator.PairChars.Add(New PairChar("("c, ")"c))

        Dim cellStyleNotify As New CellStyleNotify()
        cellStyleNotify.InvalidCellStyle.ForeColor = Color.Red
        cellStyleNotify.InvalidCellStyle.Font = New Font(DefaultFont, FontStyle.Bold)
        cellStyleNotify.DoActionReason = ValidateReasons.EditedFormattedValueChanged

        pairCharValidator.Actions.Add(cellStyleNotify)

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

        Me.gcMultiRow1.Template = template
        label.Text = "The PairCharValidator.PairChars is '( )', in edit mode, if you input '2*(3+4' to trigger validation, 
validation fails, the font is changed, if input '2*(3+4)' to trigger validation, the validation succeeds."
    End Sub
Inheritance Hierarchy

System.Object
   GrapeCity.Win.MultiRow.CellValidator
      GrapeCity.Win.MultiRow.PairCharValidator

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

PairCharValidator Members
GrapeCity.Win.MultiRow Namespace
PairChar Class
CellValidator Class

 

 


Copyright © GrapeCity, inc. All rights reserved.