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
close icon

Messagebox appearing instrad of exception

Hi Steve,

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 = "";
}

Best regards,
Haneef

7 Replies

SR Steve Rose May 18, 2007 08:43 AM UTC

Some of our users are reporting getting a message box appearing, which is not one of ours.

It says:
"Specified argument was out of the range of valid values. Parameter name: rowIndex"

Do you know why this might be appearing instead of throwing an exception to the method which is calling the grid incorrectly?

Is there any way we can track down what's causing it, as there is no stack trace or anything?

We're using a virtual grid if that helps!

Cheers
Steve



AD Andy D June 14, 2007 09:44 AM UTC

Hi,

I'm having the same problem when a user drags info out of the grid and into excel a message box appears.

I can't find a CurrentCellErrorMessage event for a GridControl. Is there another way to trap these messages?

Andy


HA haneefm Syncfusion Team June 14, 2007 05:55 PM UTC

Hi Andy,

The CurrentCellErrorMessage has newly added in Essential Studio V4.2. In older version ( before V4.2 ) , you can customize/avoid the error messagebox in a cell by handling the CurrentCellValidating or CurrentCellValidate or CurrentCellValidateString event in a grid. Please refer to the below KB article for more details.

What are the different validation events and event members? When are they triggered and how are they used?

Best Regards,
Haneef


AD Andy D June 18, 2007 02:15 PM UTC

Hi Haneef,

I implemented the event handlers described above but none of them were hit when I dragged and dropped into Excel. I looked at one of the samples that had d&d and found that it took the values from the cell and moved them rather than copying them. It may be this that is causing the issue I'm seeing (index out of range) because its removing the cells. Is there any way to force it to only copy the contents of the cells rather than move them?

Also, are there any other ways of catching this messageBox as an exception so that it's not shown to the user?

Thanks,

Andy

>Hi Andy,

The CurrentCellErrorMessage has newly added in Essential Studio V4.2. In older version ( before V4.2 ) , you can customize/avoid the error messagebox in a cell by handling the CurrentCellValidating or CurrentCellValidate or CurrentCellValidateString event in a grid. Please refer to the below KB article for more details.

What are the different validation events and event members? When are they triggered and how are they used?

Best Regards,
Haneef


HA haneefm Syncfusion Team June 18, 2007 08:06 PM UTC

Hi Andy,

To turn off style copy/paste support in a gridcontrol(allowing only text to be pasted ), turn off this flag.

this.gridControl1.Model.CutPaste.ClipboardFlags &= ~GridDragDropFlags.Styles;

Best regards,
Haneef


AD Andy D June 19, 2007 03:52 PM UTC

Hi Haneef, this still doesn't fix the underlying issue. The error appears to be an internal one from the Syncfusion grid. Do you know of any other events that I can trap that could handle this?

Thanks,

Andy


HA haneefm Syncfusion Team June 19, 2007 08:33 PM UTC

Hi Andy,

Thank you for your update.

I am not sure of what be might be causing this strange behavior without a working sample. Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon