GrapeCity MultiRow Windows Forms Documentation
CellValidateAction Class
Members  Example 


Provides the capability to execute certain actions if a Cell value fails to validate. This class is abstract (MustInherit in Visual Basic) and so cannot be instantiated.
Syntax
Public MustInherit Class CellValidateAction 
   Implements INamedObject 
Dim instance As CellValidateAction
public abstract class CellValidateAction : INamedObject  
Remarks

You can customize the action's execution by setting the DoActionReason property.

If you want to implement a custom CellValidateAction, override the DoAction method and implement your own logic in this method.

When you derive from CellValidateAction and add new properties to the derived class, be sure to override the Clone method to copy the new properties during cloning operations. Also call the base class's Clone method so that the properties of the base class are copied to the new action.
Example
The following code example shows how to use the provided CellValidators and execute different CellValidateActions for different reasons with DoActionReason.
public CellValidatorDemo()
        {
            this.Text = "CellValidator Demo";
            this.Size = new Size(660, 300);

            // Initial flow layout panel and add to form.
            this.panel.Dock = DockStyle.Left;
            this.panel.Size = new Size(200, 200);
            this.panel.FlowDirection = FlowDirection.TopDown;
            this.panel.WrapContents = false;
            this.panel.Padding = new Padding(5);
            this.panel.AutoSize = true;
            this.Controls.Add(panel);

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Left;
            this.gcMultiRow1.Width = 400;
            this.Controls.Add(this.gcMultiRow1);

            label.Height = 50;
            label.Dock = DockStyle.Bottom;
            label.BackColor = SystemColors.Info;
            label.Text = "Please Click one button to add one CellValidator and set one CellValidateAction.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            InitButton();

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            gcMultiRow1.Template = Template.CreateGridTemplate(1);
            gcMultiRow1.RowCount = 5;
        }
		
		void setRangeValidator_Click(object sender, EventArgs e)
        {
            Template template = Template.CreateGridTemplate(1);

            //Create one RangeValidator to validate whether the committed value is in 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.";
        }
Class CellValidatorDemo
    Inherits Form
    Private gcMultiRow1 As New GcMultiRow()
    Private panel As New FlowLayoutPanel()

    Public Sub New()
        Me.Text = "CellValidator Demo"
        Me.Size = New Size(660, 300)

        ' Initial flow layout panel and add to form.
        Me.panel.Dock = DockStyle.Left
        Me.panel.Size = New Size(200, 200)
        Me.panel.FlowDirection = FlowDirection.TopDown
        Me.panel.WrapContents = False
        Me.panel.Padding = New Padding(5)
        Me.panel.AutoSize = True
        Me.Controls.Add(panel)

        ' Add MultiRow to form
        Me.gcMultiRow1.Dock = DockStyle.Left
        Me.gcMultiRow1.Width = 400
        Me.Controls.Add(Me.gcMultiRow1)

        label.Height = 50
        label.Dock = DockStyle.Bottom
        label.BackColor = SystemColors.Info
        label.Text = "Please Click one button to add one CellValidator and set one CellValidateAction."
        Me.Controls.Add(label)

        InitButton()

        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        gcMultiRow1.Template = Template.CreateGridTemplate(1)
        gcMultiRow1.RowCount = 5
    End Sub
	
	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
   GrapeCity.Win.MultiRow.CellValidateAction
      GrapeCity.Win.MultiRow.AppearanceActionBase
      GrapeCity.Win.MultiRow.FocusProcess
      GrapeCity.Win.MultiRow.MessageBoxNotify
      GrapeCity.Win.MultiRow.SoundNotify
      GrapeCity.Win.MultiRow.TipNotify
      GrapeCity.Win.MultiRow.ValueProcess

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

CellValidateAction Members
GrapeCity.Win.MultiRow Namespace
CellValidator Class

 

 


Copyright © GrapeCity, inc. All rights reserved.