Back to Devexpress

WorksheetDataBindingCollection.Error Event

officefileapi-devexpress-dot-spreadsheet-dot-worksheetdatabindingcollection-24cf0712.md

latest7.4 KB
Original Source

WorksheetDataBindingCollection.Error Event

Occurs when a binding cannot be completed successfully.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
event DataBindingErrorEventHandler Error
vb
Event Error As DataBindingErrorEventHandler

Event Data

The Error event's data class is DataBindingErrorEventArgs. The following properties provide information specific to this event:

PropertyDescription
BindingDirectionIndicates whose value is updated during binding.
ColumnIndexGets the index of the column in which an error occurs.
DataBindingGets a binding object whose binding caused an error.
ErrorTypeIndicates the cause of an error.
RowIndexGets the index of the row in which an error occurs.

Remarks

The Error event indicates that an error occurs in cell range data binding. The DataBindingErrorEventArgs.ErrorType property details the cause of the error, the DataBindingErrorEventArgs.BindingDirection indicates whose value is being updated during binding.

Example

View Example

csharp
private void DataBindings_Error(object sender, DataBindingErrorEventArgs e) {
    string msg = String.Format("The error {0} occurs in attempt to {1} in row with index= {2}",
        e.ErrorType.ToString(), e.BindingDirection.ToString(), e.RowIndex);
    MessageBox.Show(msg, "Binding Error");
}
vb
Private Sub DataBindings_Error(ByVal sender As Object, ByVal e As DataBindingErrorEventArgs)
    Dim msg As String = String.Format("The error {0} occurs in attempt to {1} in row with index= {2}", e.ErrorType.ToString(), e.BindingDirection.ToString(), e.RowIndex)
    MessageBox.Show(msg, "Binding Error")
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the Error event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-spreadsheet-use-cell-range-as-data-source/CS/RangeDataSource/Form1.cs#L39

csharp
rangeDS = dataRange.GetDataSource(options);
sheet.DataBindings.Error += DataBindings_Error;
#endregion #RangeAsDataSource

how-to-bind-a-worksheet-to-a-generic-list-or-a-bindinglist-data-source/CS/DataBindingToListExample/Form1.cs#L13

csharp
#region #DataBindingErrorHandling
spreadsheetControl1.Document.Worksheets[0].DataBindings.Error += DataBindings_Error;
#endregion #DataBindingErrorHandling

wpf-spreadsheet-bind-a-worksheet-to-generic-list-or-bindinglist-data-source/CS/DataBindingToListExample/MainWindow.xaml.cs#L30

csharp
#region #ErrorSubscribe
spreadsheetControl1.Document.Worksheets[0].DataBindings.Error += DataBindings_Error;
#endregion #ErrorSubscribe

spreadsheet-document-api-data-binding/CS/SpreadsheetApiDataBinding/Program.cs#L23

csharp
BindWeatherReportToFixedTable(MyWeatherReportSource.Data, workbook.Worksheets[2]);
workbook.Worksheets[0].DataBindings.Error += DataBindings_Error;
workbook.SaveDocument("DataBindings.xlsx");

winforms-spreadsheet-use-cell-range-as-data-source/VB/RangeDataSource/Form1.vb#L44

vb
rangeDS = dataRange.GetDataSource(options)
            AddHandler sheet.DataBindings.Error, AddressOf DataBindings_Error
#End Region ' #RangeAsDataSource

how-to-bind-a-worksheet-to-a-generic-list-or-a-bindinglist-data-source/VB/DataBindingToListExample/Form1.vb#L15

vb
#Region "#DataBindingErrorHandling"
            AddHandler spreadsheetControl1.Document.Worksheets(0).DataBindings.Error, AddressOf DataBindings_Error
#End Region ' #DataBindingErrorHandling

wpf-spreadsheet-bind-a-worksheet-to-generic-list-or-bindinglist-data-source/VB/DataBindingToListExample/MainWindow.xaml.vb#L32

vb
' #Region "#ErrorSubscribe"
            AddHandler spreadsheetControl1.Document.Worksheets(0).DataBindings.Error, AddressOf DataBindings_Error
' #End Region ' #ErrorSubscribe

spreadsheet-document-api-data-binding/VB/SpreadsheetApiDataBinding/Program.vb#L22

vb
BindWeatherReportToFixedTable(MyWeatherReportSource.Data, workbook.Worksheets(2))
AddHandler workbook.Worksheets(0).DataBindings.Error, AddressOf DataBindings_Error
workbook.SaveDocument("DataBindings.xlsx")

See Also

WorksheetDataBindingCollection Interface

WorksheetDataBindingCollection Members

DevExpress.Spreadsheet Namespace