Category / Section
How to turn off the data validation error message in WinForms GridControl?
2 mins read
Show or hide error message
In order to
show or hide error messages that are displayed in the GridControl while
validating the cell, the ShowErrorMessageBox property can be
used. It can also be done using CurrentCellErrorMessage event.
In this article, both solutions have been illustrated.
// Specifies the condition.
this.gridControl1.ColStyles[1].CellValueType = typeof(Int32);
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
// Enable or disable the Error message.
this.gridControl1.CurrentCell.ShowErrorMessageBox = this.checkBox1.Checked;
}
// By handling the CurrentCellErrorMesage event the ErrorMessage box can also be hidden.
this.gridControl1.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(gridControl1_CurrentCellErrorMessage);
this.gridControl1.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(gridControl1_CurrentCellErrorMessage);
void gridControl1_CurrentCellErrorMessage(object sender, GridCurrentCellErrorMessageEventArgs e)
{
// Hides the error message.
e.Cancel = true;
}'Specifies the condition.
Me.gridControl1.ColStyles(1).CellValueType = GetType(Int32)
Private Sub checkBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
' Enable or disable the Error message.
Me.gridControl1.CurrentCell.ShowErrorMessageBox = Me.checkBox1.Checked
End Sub
'By handling the CurrentCellErrorMesage event the error message box can also be hidden.
AddHandler Me.gridControl1.CurrentCellErrorMessage, AddressOf gridControl1_CurrentCellErrorMessage
Private Sub gridControl1_CurrentCellErrorMessage(ByVal sender As Object, ByVal e As GridCurrentCellErrorMessageEventArgs)
'Hides the error message.
e.Cancel = True
End SubThe
screenshot below illustrates how to show or hide the error messages.

Samples:
C#: ErrorMessage_CS
VB: ErrorMessage_VB
Reference Link: Data Validation