GrapeCity MultiRow Windows Forms Documentation
RowValidating Event
Example 


Occurs when a row is validating.
Syntax
<SRDescriptionAttribute("Occurs when a row is validating.")>
<SRCategoryAttribute("Focus")>
<FeatureAttribute(Name="UISelection", Version="v5.0")>
Public Event RowValidating As EventHandler(Of CellCancelEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of CellCancelEventArgs)
 
AddHandler instance.RowValidating, handler
[SRDescription("Occurs when a row is validating.")]
[SRCategory("Focus")]
[Feature(Name="UISelection", Version="v5.0")]
public event EventHandler<CellCancelEventArgs> RowValidating
Event Data

The event handler receives an argument of type CellCancelEventArgs containing data related to this event. The following CellCancelEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs)
CellIndexGets the cell index in its parent Section.  
CellNameGets the cell name.  
RowIndexGets the index of the owner Row that the event occurs for.  
ScopeGets the cell area that the event occurs for.  
SectionIndexGets the index of the owner Section that the event occurs for.  
Remarks
This event is analogous to the System.Windows.Forms.Control.Validating event. Use this event to perform validation on all the values of a row.
Example
The following code example shows how to use this event to validate a row value. To run this example, create a windows form, and add a GcMultiRow control to the form. Add a RowHeaderCell and a TextBoxCell named "Name" to the MultiRow controls template. Add the event handle of this event and copy the following code into the event handler. Input some invalid values and try to move focus.
void gcMultiRow1_RowValidating(object sender, CellCancelEventArgs e)
        {
            if (e.CellName == "Name" && this.gcMultiRow1[e.RowIndex, "Name"].Value == null)
            {
                e.Cancel = true;

                // Set error text to why the cell validation failed.
                this.gcMultiRow1.Rows[e.RowIndex].ErrorText = "The student name can't be empty, please input the 
name.";
            }
            else
            {
                this.gcMultiRow1.Rows[e.RowIndex].ErrorText = string.Empty;
            }
        }
Private Sub gcMultiRow1_RowValidating(ByVal sender As Object, ByVal e As CellCancelEventArgs) Handles gcMultiRow1.RowValidating
        If e.CellName = "Name" AndAlso Me.gcMultiRow1(e.RowIndex, "Name").Value = Nothing Then
            e.Cancel = True

            ' Set error text to why the cell validation failed.
            Me.gcMultiRow1.Rows(e.RowIndex).ErrorText = "The student name can't be empty, please input the name."
        Else
            Me.gcMultiRow1.Rows(e.RowIndex).ErrorText = String.Empty
        End If
    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

GcMultiRow Class
GcMultiRow Members

 

 


Copyright © GrapeCity, inc. All rights reserved.