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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to show normal MessageBox instead of showing default ErrorMessageBox for DataValidation?

Platform: WinForms |
Control: GridControl |
Published Date: September 21, 2018 |
Last Revised Date: May 27, 2019

To avoid the default error message box and display the normal message box, use the Cancel property and TableControlCurrentCellErrorMessage event.

 

C#

//Event Subscription. 
this.gridGroupingControl1.TableControlCurrentCellErrorMessage += newGridTableControlCurrentCellErrorMessageEventHandler(gridGroupingControl1_TableControlCurrentCellErrorMessage); 
 
void gridGroupingControl1_TableControlCurrentCellErrorMessage(object sender, GridTableControlCurrentCellErrorMessageEventArgs e) 
{ 
    //to cancel showing the default ErrorMessageBox support. 
    e.Inner.Cancel = true; 
 
    //To get the orginal error from e.Inner.Text 
    DialogResult result = MessageBox.Show(e.Inner.Text, "ErrorProvider", MessageBoxButtons.OKCancel); 
    if (result == DialogResult.Cancel) 
    { 
        e.TableControl.CurrentCell.CancelEdit(); 
    } 
} 

VB

'Event Subscription. 
Private Me.gridGroupingControl1.TableControlCurrentCellErrorMessage += New GridTableControlCurrentCellErrorMessageEventHandler(AddressOf gridGroupingControl1_TableControlCurrentCellErrorMessage)
 
Private Sub gridGroupingControl1_TableControlCurrentCellErrorMessage(ByVal sender As Object, ByVal e As GridTableControlCurrentCellErrorMessageEventArgs)
    'to cancel showing the default ErrorMessageBox support. 
    e.Inner.Cancel = True
 
    'To get the orginal error from e.Inner.Text 
    Dim result As DialogResult = MessageBox.Show(e.Inner.Text, "ErrorProvider", MessageBoxButtons.OKCancel)
    If result = DialogResult.Cancel Then
        e.TableControl.CurrentCell.CancelEdit()
    End If
End Sub

 

Screenshot

Showing error message for Data Validation

Sample links:

CS: Custom_Error_Message_Box

VB: Custom_Error_message_box

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