)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to turn off the data validation error message in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 15, 2016 |
Last Revised Date: December 17, 2019

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.

 

C#

// 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;
}

 

VB

' 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

 

 

Screenshot:

Show and hide the error message in GridControl

Samples:

C#: ErrorMessage_CS

VB: ErrorMessage_VB

Reference link: https://help.syncfusion.com/windowsforms/grid-control/data-validation

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon