GridView - Copy Data From Child Template to Clipboard

2 posts, 0 answers
  1. The Kawa Dev
    The Kawa Dev avatar
    2 posts
    Member since:
    Mar 2012

    Posted 22 Nov 2013 Link to this post


    Per this thread, I see that we now have proper copy functionality in the radgridview control:

    I am able to successfully use


    My question is this:
    How would I go about using this functionality in a hierarchical view, where the user wishes to copy data in the "child" template.
      does not have a corresponding "BeginRowCopy"

    When I call grid.MasterTemplate.BeginRowCopy()  I receive repeated errors stating:

    Property accessor 'Name' on object 'class name' threw the following exception: 'Object does not match target type.'

    To clarify this error, the parent table contains a column (and property corresponding to the object) called "Name".
    The child templates data does not contain a property of that name.  The obvious conclusion is that grid.MasterTemplate.BeginRowCopy() only works for the master template and does not operate on the child template.

    Any suggestions on how to accomplish this?

    Update:  Ctrl-C exhibits the same issue.

    Thank you.

    PS: It is a shame that the only documentation on the matter came from another forum post.  It would be helpful to see Copy/Paste functionality fleshed out in the WinForm Documentaiton or KB articles.

  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    3945 posts

    Posted 27 Nov 2013 Link to this post

    Hello Jordan,

    Thank you for contacting Telerik Support.

    Currently, Copy function for the child template is not supported. However, we have this issue logged in our Public Issue Tracking System - PITS. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - PITS issue.

    The possible workaround that I can propose handle manually Copy operation:
    radGridView1.ContextMenuOpening += radGridView1_ContextMenuOpening;

    string clipBoard = string.Empty;
    RadGridView contextMenuInvoker;
    private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
        RadGridView grid = sender as RadGridView;
        if (grid.CurrentCell is GridDataCellElement || grid.CurrentCell is GridTableBodyElement)
            if (grid.CurrentRow.ViewTemplate != grid.MasterGridViewTemplate && !(grid.CurrentCell.RowInfo is GridViewNewRowInfo))
                RadMenuItem itemCopy = new RadMenuItem();
                itemCopy.Text = "Copy Row(s)";
                itemCopy.Click += new EventHandler(itemCopy_Click);
                e.ContextMenu.Items.Insert(3, itemCopy);
            contextMenuInvoker = grid;
    void itemCopy_Click(object sender, EventArgs e) 
    private void CopyRows(RadGridView radGridView)
        StringBuilder sb = new StringBuilder();
        foreach (GridViewRowInfo row in radGridView.SelectedRows)
            int i = 0;
            while (i < row.Cells.Count)
                if (i > 0)
        clipBoard = sb.ToString();

    P.S. We will consider including Copy/Paste functionality in RadGridView help section.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top