There is a exception when I call following code:
xamDataGrid.ExecuteCommand(ApplicationCommands.Cut);
the exception say:
Unable to perform the operation. Additional Information:
OpenClipboard Failed(Exception from HRESULT:0x800401D0(CLIPBRD_E_CANT_OPEN))
Anyone know how to avoid it?
Hello Vinodh,
Thank you for your post. I have been looking into it and I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Hi Infragistics, I am also getting the same problem when trying to copy the XAMDataGrid to clipboard by calling the following code.
"xamlGrid.ExecuteCommand(DataPresenterCommands.Copy);"
I am getting a messageBox as below:
*******************************************************************************************************
---------------------------
Copy Error---------------------------Unable to perform the operation. Additional Information: OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))---------------------------OK ---------------------------
The operation is successfully copying the data to clipboard, but the only problem is this messagebox. Dont know how to suppress this messagebox.
Any solutions provided for this issues in any latest versions?
Thanks,
Vinodh
Basically during a cut, we first take the cell(s) data and try to put it in the clipboard using the Clipboard.SetDataObject. If that fails (i.e. raises an exception like the one that Clipboard does when it cannot open the clipboard) then we do not proceed with the cut operation but just raise the ClipboardError event which by default will show a message box with the exception information.
My application popup a dialog to say OpenClipboard is failed. I think it is not a exception and my application is not crash. And in fact the data has been copied in Clipboard(I can check it by clipbrd). But it did not clean the data in the cell (I call ApplicationCommands.Cut)
Both the WPF and WinForms Clipboard classes in .Net rely upon the COM clipboard infrastructure and since only 1 process can have the clipboard at a time there are times when it will fail. The WinForms Clipboard differs from the WPF Clipboard in that it will retry a few times if the first time fails. The change that we made based on the linked to post was to build in such a retry attempt as well since we're dealing with the WPF clipboard. It is still possible that it will fail if the clipboard could not be opened. Also, if you have VS set to break on all exceptions then you will get first chance exceptions when the calls to (Get|Set)DataObject are made and the clipboard access could not be obtained. So are you getting first chance exceptions (i.e. handled) or are you saying that you application is crashing?