Hi!
I need to allow copy/paste of a row in a wingrid. The problem is that I have 2 cells that are read-only. So when I paste the row, I received an error asking me to continue to copy in the read-only cell or cancel. If I click OK then everything works fine. My question is How can I deactivate this message to always paste (with copy cell content in read-only cells) without warnings and message boxes ?
I looked in the WinGrid Error event and found MultiCellOperationErrorInfo object, but I didn't find the way to correct this behavior.
Best regards,
Benoit
Hi Benoit,
I think you should be able to achieve what you want with something like this:
private void ultraGrid1_Error(object sender, Infragistics.Win.UltraWinGrid.ErrorEventArgs e) { if (e.ErrorType == ErrorType.MultiCellOperation) { if (e.MultiCellOperationErrorInfo.Operation == MultiCellOperation.Paste && e.MultiCellOperationErrorInfo.CanContinueWithRemainingCells) { e.MultiCellOperationErrorInfo.Action = MultiCellOperationErrorInfo.ErrorAction.Continue; e.Cancel = true; } } }
Hi Mike!
It works great. Thanks. But I still have a problem. I have cells that contains decimal numbers with a display format (to see them as money) and a mask input and these cells do not paste correctly. After paste, the cells contains 0,00$ instead of the amount. Can you explain me why I have this problem ?
I have another decimal number that its display format is percent and the paste works.
I'm not sure why that would happen. Can you post a small sample project that demonstrates this issue?
What was the value before you pasted it?
Hi,
I am having the above issue.
I have 10 cells with null values. The grid used to show the message 10 times.
I used your code in this article. Now it is not showing the error 10 times. But it is showing 1 time.
I want to getrid of showing the error 1 time also.
Could you please guide me how to resolve this issue?
Thanks inadvance.
Venkat.
Hi Mike,
Thank you very much. It's resolved my issue.
Regards,
Hi Venkat,
It sounds to me like you just need to shift the code around a little:
private void ultraGrid1_Error(object sender, Infragistics.Win.UltraWinGrid.ErrorEventArgs e) { if (e.ErrorType == ErrorType.MultiCellOperation) { if (e.MultiCellOperationErrorInfo.Operation == MultiCellOperation.Paste) { if (e.MultiCellOperationErrorInfo.CanContinueWithRemainingCells) e.MultiCellOperationErrorInfo.Action = MultiCellOperationErrorInfo.ErrorAction.Continue; e.Cancel = true; } } }
I checked for why CanContinueWithRemainingCells is false. It's because, from the cell I pasted the last cell is null. So when it come to the Error event for the last cell, CanContinueWithRemainingCells is false because there are no more cells to continue. So it is set to false for the last cell.
I pasted few cells with the last cell not null, then I didn't get the error message one time also.
Is there a way to find that the event is raised for the last cell?
Thanks,
Thanks for your reply.
I debugged the Error event. e.Cancel is not set to true because of
e.MultiCellOperationErrorInfo.CanContinueWithRemainingCells is false in once case.
So it's not going inside that if block and not setting e.Cancel to true.
Could you please let me know, how can I override this value? or Is there any alternative solution for this?
Thanks in Advance.
If you are seeing the error message, then the code must not be getting hit once and therefore the Cancel property is never set to true.
Put a breakpoint in the error event and see what's happening and why it's going through the code without setting e.Cancel. Maybe the 'if' block above is not catching every case you need.