Copying row data from GridView?

9 posts, 2 answers
  1. Peter Luth
    Peter Luth avatar
    26 posts
    Member since:
    Aug 2007

    Posted 02 Jul 2008 Link to this post

    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.
  2. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 02 Jul 2008 Link to this post

    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
  3. Peter Luth
    Peter Luth avatar
    26 posts
    Member since:
    Aug 2007

    Posted 03 Jul 2008 Link to this post

    Thanks for the workaround. I hope you will support this is the future, since copy/pasting is a pretty standard operation :-)
  4. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 04 Jul 2008 Link to this post

    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
  5. Answer
    carla
    carla avatar
    5 posts
    Member since:
    May 2011

    Posted 10 Aug 2011 Link to this post

    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
  6. Julio Colon
    Julio Colon avatar
    13 posts
    Member since:
    May 2010

    Posted 04 Nov 2011 Link to this post

    Is this supported in the 2011 version?
  7. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 07 Nov 2011 Link to this post

    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.

  8. Julio Colon
    Julio Colon avatar
    13 posts
    Member since:
    May 2010

    Posted 07 Nov 2011 Link to this post

    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

  9. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 10 Nov 2011 Link to this post

    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.

Back to Top