Articles in this section
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 in 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 the solutions had 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.
Private Me.gridControl1.CurrentCellErrorMessage += New GridCurrentCellErrorMessageEventHandler(AddressOf gridControl1_CurrentCellErrorMessage)
Private Sub gridControl1_CurrentCellErrorMessage(ByVal sender As Object, ByVal e As GridCurrentCellErrorMessageEventArgs)
   ' Hides the error message. 
   e.Cancel = True
End Sub




Show and hide the error message in GridControl


C#: ErrorMessage_CS

VB: ErrorMessage_VB

Reference link:

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied