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

Copying row data from GridView?

8 Answers 391 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter Luth
Top achievements
Rank 1
Peter Luth asked on 02 Jul 2008, 10:31 AM
Hello,

We are using RadGridView in a read-only mode. When our customers select a row, right click and use "Copy", nothing is copied to clipboard. Why is this? What is the best way to allow the user to copy data from the GridView into clipboard?

Thanks.

8 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 02 Jul 2008, 10:55 PM
Hello Martin,

Thank you for contacting us and for the good question.

Unfortunately, we do not support cliboard operations yet, althouth we are considering the implemention of this feature.

As a quick workaround, please find beloe a code sample which shows how to copy the selected rows from RadGrid to the clipboard in CSV format:

private void radButton2_Click(object sender, EventArgs e) 
    StringBuilder sb = new StringBuilder(); 
 
    foreach (GridViewRowInfo row in this.radGridView1.SelectedRows) 
    { 
        for (int i = 0; i<row.Cells.Count; i++) 
        { 
            if (i > 0) 
                sb.Append(","); 
            sb.Append(row.Cells[i].Value.ToString()); 
        } 
        sb.Append(Environment.NewLine); 
    } 
 
    Clipboard.SetDataObject(sb.ToString()); 


Do not hesitate to write me if you have other questions.

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Peter Luth
Top achievements
Rank 1
answered on 03 Jul 2008, 06:47 AM
Thanks for the workaround. I hope you will support this is the future, since copy/pasting is a pretty standard operation :-)
0
Jack
Telerik team
answered on 04 Jul 2008, 07:17 AM
Hello Martin,

I am glad to hear that the issue has been resolved.

We will add copy/paste support in one of our upcoming releases.

Thank you for the good suggestion.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Accepted
carla
Top achievements
Rank 1
answered on 10 Aug 2011, 08:23 PM
I want to traverse the grid cell just like below but could not in version 2011.1.315.1040. Basically, i can actually do radGridView.SelectedItems.OfType<Employee> but this will give me an object and won't be able to tell whether the column is shown.

Never mind. found the answer... I used ICommand instead
0
Julio Colon
Top achievements
Rank 1
answered on 04 Nov 2011, 10:22 PM
Is this supported in the 2011 version?
0
Jack
Telerik team
answered on 07 Nov 2011, 04:48 PM
Hi Julio Colon,

Could you please confirm that your question is related to the copy & paste support in RadGridView? If this is not the case, could you elaborate a bit more and specify your question in detail.

Yes, we support copy & paste operation between grid cells. However, we do not support copy & paste between RadGridView and other controls or forms. For this purpose you can use the solution offered in this thread. Please note that the internal copy & paste mechanism is disabled when using RadGridView in read only mode.

I hope this helps.
 
Greetings,
Jack
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Julio Colon
Top achievements
Rank 1
answered on 07 Nov 2011, 05:20 PM
This is my user story:

As a developer,
I wants to copy the content in a RadGridView and paste it into the clipboard with an easy function in the RadGridView class.
In order to help our users move the data out to their favorite spreadsheet.

Julio

0
Jack
Telerik team
answered on 10 Nov 2011, 11:05 AM
Hello Julio Colon,

Thank you for your feedback 

As I said in my previous post, currently RadGridView supports copy & paste operations only between cells. The only option is to use the solution offered in this thread. I logged this as a feature request in our issue tracking system and updated your Telerik points accordingly. 

Should you have any further questions, do not hesitate to ask.

Best wishes,
Jack
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
GridView
Asked by
Peter Luth
Top achievements
Rank 1
Answers by
Jack
Telerik team
Peter Luth
Top achievements
Rank 1
carla
Top achievements
Rank 1
Julio Colon
Top achievements
Rank 1
Share this question
or