Back to Devexpress

ColumnView.DataError Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-118e54bc.md

latest2.6 KB
Original Source

ColumnView.DataError Event

Fires when an error occurs in the data controller and allows you to handle the error.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Action")]
public event EventHandler<ColumnViewDataErrorEventArgs> DataError
vb
<DXCategory("Action")>
Public Event DataError As EventHandler(Of ColumnViewDataErrorEventArgs)

Event Data

The DataError event's data class is DevExpress.XtraGrid.Views.Base.ColumnViewDataErrorEventArgs.

Remarks

The grid control displays a tooltip if there is an error in the data controller:

The DataError event allows you to handle errors in the data controller.

You can modify the error message displayed in the tooltip:

csharp
using DevExpress.XtraGrid.Views.Base;

void gridView1_DataError(object sender, ColumnViewDataErrorEventArgs e) {
    e.DisplayMessage = "Specify a custom error message.";
}
vb
Imports DevExpress.XtraGrid.Views.Base

Private Sub gridView1_DataError(ByVal sender As Object, ByVal e As ColumnViewDataErrorEventArgs)
    e.DisplayMessage = "Specify a custom error message."
End Sub

Set the e.Handled property to true to hide the tooltip. The following example logs the error and hides the tooltip:

csharp
using DevExpress.XtraGrid.Views.Base;

void gridView1_DataError(object sender, ColumnViewDataErrorEventArgs e) {
    Log(e.DataException.Message);
    e.Handled = true;
}
vb
Imports DevExpress.XtraGrid.Views.Base

Private Sub gridView1_DataError(ByVal sender As Object, ByVal e As ColumnViewDataErrorEventArgs)
    Log(e.DataException.Message)
    e.Handled = True
End Sub

See Also

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace