This is a migrated thread and some comments may be shown as answers.

gridview Copying and Pasting

5 Answers 346 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erdem
Top achievements
Rank 1
Erdem asked on 21 Aug 2014, 06:12 PM
   Hi I write this code and I m trying someting . But when i click copying event then 3 times show messagebox "a" but  when i click pasting event then messagebox show 1 times "a".. Why copying event show 3 times ??

       private void radGridView1_Copying(object sender, GridViewClipboardEventArgs e)
        {
            MessageBox.Show("a");
            

        }

        private void radGridView1_Pasting(object sender, GridViewClipboardEventArgs e)
        {
            MessageBox.Show("a");
        }

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 22 Aug 2014, 08:02 AM
Hi Erdem,

Thank you for writing.

Here is a quote from our documentation regarding the copying event:
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: DataFormats.Text, DataFormats.HTML, DataFormats.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:
 
I hope this clear things up. Let me know if you have any additional questions.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Karl B
Top achievements
Rank 1
answered on 14 Oct 2015, 05:07 PM

This appears to happen when pasting directly from Excel. If I copy from excel and paste into the grid it will fire Pasting for HTML, Text AND CSV. 

 Is there any way to suppress this behavior?

0
Stefan
Telerik team
answered on 15 Oct 2015, 05:45 AM
Hi Karl,

The observed behavior is desired and expected and cannot be suppressed. We are checking what is the format of the data in the clipboard and we are firing the event for the respective formats. You could do the same if you want to limit to just one format.

I hope this helps.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Karl B
Top achievements
Rank 1
answered on 15 Oct 2015, 02:25 PM

Is there a way to control what format is copied from a Telerik grid row?  It appears to be coming in as HTML by default. 

I want to be able to handle copying from a text file, excel, and another grid row. If I could count on the grid data being in text format I could ignore the other formats.

0
Karl B
Top achievements
Rank 1
answered on 15 Oct 2015, 08:42 PM
Disregard my last post. I am now seeing all three formats pasted in.  I'm not sure what was going on before.
Tags
GridView
Asked by
Erdem
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Karl B
Top achievements
Rank 1
Share this question
or