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

Cell validation message box

Hello,

I know that this has been covered in these forums, but I have not been able to get it working right. All I want to do is prevent the "Input was not in correct format" messagebox from appearing at all when an invalid input is entered in a GC. My problem is that this message is appearing when users are entering blanks, which is not desirable for our application. I would rather catch this message and clear out the contents of the cell on invalid input with no message. Any help on this would be greatly appreciated. Thanks in advance.

Jarrod

3 Replies

AD Administrator Syncfusion Team December 9, 2006 12:34 AM UTC

One way you can try to do this is to handle the CurrentCellErrorMessage event. You can cancel this event to avoid the error message displaying. You can also reset the current text if you want to. Here is some code snippets.

private void Form1_Load(object sender, EventArgs e)
{
//make all cells doubles so errors are generated when you type something other than a double
this.gridControl1.TableStyle.CellValueType = typeof(double);

gridControl1.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(grid_CurrentCellErrorMessage);
}

void grid_CurrentCellErrorMessage(object sender, GridCurrentCellErrorMessageEventArgs e)
{
e.Cancel = true;
this.gridControl1.CurrentCell.Renderer.Control.Text = "";
}


JB James Blibo January 29, 2007 07:18 PM UTC

How can I customize the tooltip message that is show? I want to add something like 'Press ESC' to cancel changes' for example to the message. Maybe even the column name!


AD Administrator Syncfusion Team January 29, 2007 08:09 PM UTC

Hi James,

If you want to change the error tooltip text in a grid then you can hanlde the TableControlCurrentCellErrorMessage and set the custom error tooltip using CurrentRecordProperty.Exception property. Here is a code snippet to show this.

private void gridGroupingControl1_TableControlCurrentCellErrorMessage(object sender, GridTableControlCurrentCellErrorMessageEventArgs e)
{
GridGroupingControl grid = sender as GridGroupingControl;
foreach(CurrentRecordProperty prop in grid.Table.CurrentRecordManager.Properties)
{
if( prop.IsError)
prop.Exception = new Exception("Your ToolTip Message Here",prop.Exception.InnerException);
}
}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon