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.
Unfortunately, activation email could not send to your email. Please try again.

how to Handle violating constaints error message in griddatabound

Thread ID:

Created:

Updated:

Platform:

Replies:

20232 Oct 12,2004 04:43 PM Nov 29,2005 12:51 AM Windows Forms 5
loading
Tags: GridControl
tang
Asked On October 12, 2004 04:43 PM

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 01:20 AM

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 09:13 AM

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 10:08 AM

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 10:42 AM

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 12:51 AM

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

CONFIRMATION

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.

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.

;