When using CopyingCellClipboardContent the event is fired x3 times in each cell (once for each supported format). So if I have selected 5 cells the copy will trigger the event 15 times. Is there any kind of event for multiple copies?
2 Answers, 1 is accepted
0
Nadya | Tech Support Engineer
Telerik team
answered on 21 Mar 2024, 11:02 AM
Hi, Álvaro,
There isn't special event for multiple copies. RadGridView offers Copying and CopyingCellClipboardContent events for the copy functionality. These events are fired for each supported format: Text, HTML, CommaSeparatedValue. More information is available here: Copy/Paste/Cut - RadGridView - Telerik UI for WinForms
Please let me know if you have any other questions.
Regards,
Nadya | Tech Support Engineer
Progress Telerik
A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Currently, I'm facing a problem with the Copy/Past methods. It seems that my clipboard is being replaced by Telerik at some point. So I caught the copy content event and I parsed it to my custom model (it is serializable as expected by the Clipboard) and saved it in my clipboard. If I check directly the Clipboard (in the same method) I would see my model.
Later in the paste method, I check the Clipboard and it has not my copied object, but it has different ones.
privatevoidgridView_CopyingCellClipboardContent(object sender, GridViewCellValueEventArgs e)
{
// Get my model from e
CustomModel myModel = e... ;
DataObject dataObject = new DataObject("CustomModel", myModel);
Clipboard.SetDataObject(dataObject, true);
// Check the formats are ok:
IDataObject iData = Clipboard.GetDataObject();
var formats = iData.GetFormats();
// Formats array: ["CustomModel"]// I could get the model here with no problem
}
privatevoidgridView_PastingCellClipboardContent(object sender, GridViewCellValueEventArgs e)
{
IDataObject iData = Clipboard.GetDataObject();
// Check if my data exists but it is not: falseif (iData.GetDataPresent("CustomModel"))
{
// Unreached code
}
// Check the formats, my saved object does not existsvar formats = iData.GetFormats();
// ["System.String","UnicodeText","Text"] but not mine
}
0
Nadya | Tech Support Engineer
Telerik team
answered on 26 Mar 2024, 07:54 AM
Hello, Álvaro,
Thank you for the provided code snippet. However, it is not enough for me to replicate the exact problem that you are facing. I am able to copy and paste the text as expected on my end according to supported formats. Usually, RadGridView would paste what it is already stored into the clipboard. You said that after checking the clipboard in the PastingCellClipboardContent event it is not your copied object but a different one. This would be very strange.
Is it possible to provide a sample project where you can demonstrate this specific problem? Without replicating the exact problem, it would be difficult to determine what exactly is happening on your end. Thank you in advance for your understanding.
Looking forward to your reply.
Regards,
Nadya | Tech Support Engineer
Progress Telerik