GrapeCity MultiRow Windows Forms Documentation
RegexOptions Property
Example 


Gets or sets the regular expression options.
Syntax
<SRDescriptionAttribute("Indicates the regex options.")>
<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")>
<SuppressMessageAttribute(Category="Microsoft.Performance", 
   CheckId="CA1804:RemoveUnusedLocals", 
   Scope="", 
   Target="", 
   MessageId="regex", 
   Justification="")>
<DefaultValueAttribute()>
Public Property RegexOptions As RegexOptions
Dim instance As RegularExpressionValidator
Dim value As RegexOptions
 
instance.RegexOptions = value
 
value = instance.RegexOptions
[SRDescription("Indicates the regex options.")]
[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")]
[SuppressMessage(Category="Microsoft.Performance", 
   CheckId="CA1804:RemoveUnusedLocals", 
   Scope="", 
   Target="", 
   MessageId="regex", 
   Justification="")]
[DefaultValue()]
public RegexOptions RegexOptions {get; set;}

Property Value

A bitwise combination of the System.Text.RegularExpressions.RegexOptions. The default is System.Text.RegularExpressions.RegexOptions.None.
Exceptions
ExceptionDescription
System.ComponentModel.InvalidEnumArgumentExceptionThe assigned value is not a valid System.Text.RegularExpressions.RegexOptions value.
System.ArgumentException The assigned value is a conjunction with invalid enumeration values.
Remarks
Enumeration combinations are validated when setting this property.
Example
The following code example uses the RegularExpressionValidator to validate whether the input value matches Expression, which indicates a currency value. If 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 Expression. The FocusProcess occurs. If you input '-12.05', it 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
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

RegularExpressionValidator Class
RegularExpressionValidator Members
Expression Property

 

 


Copyright © GrapeCity, inc. All rights reserved.