officefileapi-devexpress-dot-spreadsheet-dot-worksheetdatabindingcollection-24cf0712.md
Occurs when a binding cannot be completed successfully.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
event DataBindingErrorEventHandler Error
Event Error As DataBindingErrorEventHandler
The Error event's data class is DataBindingErrorEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| BindingDirection | Indicates whose value is updated during binding. |
| ColumnIndex | Gets the index of the column in which an error occurs. |
| DataBinding | Gets a binding object whose binding caused an error. |
| ErrorType | Indicates the cause of an error. |
| RowIndex | Gets the index of the row in which an error occurs. |
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.
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");
}
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
rangeDS = dataRange.GetDataSource(options);
sheet.DataBindings.Error += DataBindings_Error;
#endregion #RangeAsDataSource
#region #DataBindingErrorHandling
spreadsheetControl1.Document.Worksheets[0].DataBindings.Error += DataBindings_Error;
#endregion #DataBindingErrorHandling
#region #ErrorSubscribe
spreadsheetControl1.Document.Worksheets[0].DataBindings.Error += DataBindings_Error;
#endregion #ErrorSubscribe
spreadsheet-document-api-data-binding/CS/SpreadsheetApiDataBinding/Program.cs#L23
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
rangeDS = dataRange.GetDataSource(options)
AddHandler sheet.DataBindings.Error, AddressOf DataBindings_Error
#End Region ' #RangeAsDataSource
#Region "#DataBindingErrorHandling"
AddHandler spreadsheetControl1.Document.Worksheets(0).DataBindings.Error, AddressOf DataBindings_Error
#End Region ' #DataBindingErrorHandling
' #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
BindWeatherReportToFixedTable(MyWeatherReportSource.Data, workbook.Worksheets(2))
AddHandler workbook.Worksheets(0).DataBindings.Error, AddressOf DataBindings_Error
workbook.SaveDocument("DataBindings.xlsx")
See Also
WorksheetDataBindingCollection Interface