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 Handle violating constaints error message in griddatabound

Thread ID:





20232 Oct 12,2004 08:43 PM UTC Nov 29,2005 05:51 AM UTC WinForms 5
Tags: GridControl
Asked On October 12, 2004 08:43 PM UTC

Hello I set the primiary keys of datasource to control duplicate row entry in my grid. if the user enters a duplicate value for the primary key column, they get a built in error generated by the grid itself warning them of this error. Do you know how I can stop this message and use my messagebox ? is there any events I can catch?

Administrator [Syncfusion]
Replied On October 13, 2004 05:20 AM UTC

Hi Yang, you can handle the groupingControl.ExceptionRaised event and set e.Cancel = true. Then you can display your own messagebox there. Stefan

Administrator [Syncfusion]
Replied On October 13, 2004 01:13 PM UTC

If this is a GridDataBoundGrid, then try handling the grid''s ValidateFailed event. There to provide your own message, set grid.CurrentCell.ErrorMessage.
private void gridDataBoundGrid1_ValidateFailed(object sender, GridValidateFailedEventArgs e)
	this.gridDataBoundGrid1.CurrentCell.ErrorMessage = "My message";

Abdul Shahzad
Replied On November 28, 2005 03:08 PM UTC

Hi Clay, This works fine if the user key-in invalid value and leave the cell either by pressing Tab or arrow button or mouse. But fails if Enter key is hit i.e. if the user hit Enter key after invalid value then same Grid''s buil-in error message is show. In clue on how to handle this. Regards, Shahzad

Administrator [Syncfusion]
Replied On November 28, 2005 03:42 PM UTC

One thing that might work is to catch the Enter key and turn it into a Tab key. You can do this by handling the CurrentCellKeyDown event.
private void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
	if(e.KeyCode == Keys.Enter)
		e.Handled = true;//ignore Enter
		SendKeys.Send("{TAB}");//do a tab

Abdul Shahzad
Replied On November 29, 2005 05:51 AM UTC

Thanks Clay.It work''s fine!!!


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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