GrapeCity MultiRow Windows Forms Documentation
DataError Event
Example 


Occurs when an external data parsing or validation operation throws an exception, or when an attempt to commit data to a data source fails.
Syntax
<FeatureAttribute(Name="DataError", Version="v5.0")>
<SRDescriptionAttribute("Occurs when an external data-parsing or validation operation throws an exception, or when an attempt to commit data to a data source does not succeed.")>
<SRCategoryAttribute("Behavior")>
Public Event DataError As EventHandler(Of DataErrorEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of DataErrorEventArgs)
 
AddHandler instance.DataError, handler
[Feature(Name="DataError", Version="v5.0")]
[SRDescription("Occurs when an external data-parsing or validation operation throws an exception, or when an attempt to commit data to a data source does not succeed.")]
[SRCategory("Behavior")]
public event EventHandler<DataErrorEventArgs> DataError
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs)
CellIndexGets the cell index in its parent Section. (Inherited from GrapeCity.Win.MultiRow.CellCancelEventArgs)
CellNameGets the cell name. (Inherited from GrapeCity.Win.MultiRow.CellCancelEventArgs)
ContextGets the context of this data error.  
ExceptionGets the thrown exception that caused the data error.  
RowIndexGets the index of the owner Row that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellCancelEventArgs)
ScopeGets the cell area that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellCancelEventArgs)
SectionIndexGets the index of the owner Section that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellCancelEventArgs)
ThrowExceptionGets a value that indicates whether to throw an exception.  
Remarks
If you do not handle this event, a message box is shown when there is an exception that has been thrown in the GcMultiRow control. If you handle this event, this event fires instead of showing the message box.
Example
The following code example shows how to use this event to handle errors in the MultiRow control. This code example is part of a larger example provided for the DataSource property.
void gcMultiRow1_DataError(object sender, DataErrorEventArgs e)
       {
           // The first id cell can only input numbers, if user inputs an invalid value, DataError event is fired.
           // You should handle this event to handle some error cases.
           if ((e.Context & DataErrorContexts.Commit) != 0)
           {
               // When committing value occurs error, show a message box to notify user, and roll back value.
               MessageBox.Show(e.Exception.Message);
               EditingActions.CancelEdit.Execute(this.gcMultiRow1);
           }
           else
           {
               // Other handle.
           }
       }
Private Sub gcMultiRow1_DataError(ByVal sender As Object, ByVal e As DataErrorEventArgs) Handles 
gcMultiRow1.DataError

        ' The first id cell can only input numbers, if user inputs an invalid value, DataError event is fired.
        ' You should handle this event to handle some error cases.
        If (e.Context And DataErrorContexts.Commit) <> 0 Then
            ' When committing value occurs error, show a message box to notify user, and roll back value.
            MessageBox.Show(e.Exception.Message)
            EditingActions.CancelEdit.Execute(Me.gcMultiRow1)
            ' Other handle.
        Else
        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.