This is a migrated thread and some comments may be shown as answers.
Copy a Cell throws an exception
2 Answers 31 Views
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 23 Oct 2020, 12:59 AM

Hi Guys

I can't work out why , but every cell in every grid in my application ( different forms and Grids) all throw an exception when you try to copy a cell.

This happens for both the right click, select copy , or with Ctrl C 

System.Runtime.InteropServices.COMException occurred
Message: Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Windows.Forms.dll
Additional information: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))

 

 

Been googling like mad , found the info about copy events for the grid. These seem to fire (3 times each for each format) and then the exception happens. Even calling cancel in the event or trying to format the value returned still causes the exception.

I am using version v4.0.30319 , but I don't see any fixes in later versions for this.

Some trouble shooting ideas would be greatly appreciated

 

Regards

Rob

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Oct 2020, 10:23 AM
Hello, Rob, 

RadGridView introduces Copying event which occurs when the grid has prepared appropriate data formats that represent the copy selection. This event is fired once for each supported format:Text, HTML, CommaSeparatedValue. You can cancel this event if the data is not allowed to be stored to Clipboard in a specific format, e.g. HTML format.

According to the provided information, it wouldn't be easy to determine how to replicate the issue locally and whether the RadGridView control actually causes it. Could you please specify the exact steps how to reproduce the problem or get back to me with a sample project so I can investigate the precise case? I believe that the same behavior will be observed with the MS DataGridView.

After some research in general programming forums, it seems that it is a common problem. Please refer to the following threads which are quite useful on this topic:
https://stackoverflow.com/questions/5093264/cryptic-exception-copy-pasting-from-datagridview-into-excel-2002 
https://social.msdn.microsoft.com/Forums/windows/en-US/0cb6c5a9-524e-4725-83c6-09853b2f6da5/setdataobject-troubles?forum=winforms 
https://developercommunity.visualstudio.com/content/problem/751272/exception-on-clipboardsetdataobject.html 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Rob
Top achievements
Rank 1
answered on 28 Oct 2020, 01:48 AM

Hey Dess

I do have a MS DataGridView in the same application ( shocking I know!) and that does not throw an exception when copying a cell. However , the data never appears in the clip board.

After reading those links ( your google skills are clearly superior) , I tried building a new project from scratch with nothing but a RadGrid with a few columns and nothing more. If I run this in VS , add a row of data and try the copy.. same exception.

So I tried the compiled file on another pc and it worked fine.. then I finally tried running the compiled file on my development machine and it works fine. 

So it seems to be a VS issue and I am sure something specific to this development machine. 

Thank you for the assistance. 

 

Rob

Asked by
Rob
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Rob
Top achievements
Rank 1
Share this question
or