Copy grid

2 posts, 0 answers
  1. Artemis
    Artemis avatar
    5 posts
    Member since:
    Jul 2015

    Posted 10 Oct Link to this post

    Hi.

    I am using the "Copy" command from the right-click menu and it works OK in copying selected cells to the clipboard and then pasting into another program.

    However, I want to copy the entire grid, including column and row headers.

    The headers cannot be selected.

    Is there a way to copy the entire grid to clipboard?

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 12 Oct Link to this post

    Hello Artemis,

    Thank you for writing.  

    Header cells are not supposed to be selected and hence, they are not supposed to be copied. However, you can override the PivotGridContextMenu.OnCopyMenuItemClick method, get the clipboard data and customize it according to your requirement and then set the new data.
    this.radPivotGrid1.PivotGridElement.ContextMenu = new CustomPivotGridContextMenu(this.radPivotGrid1.PivotGridElement);

    public class CustomPivotGridContextMenu : PivotGridContextMenu
    {
        public CustomPivotGridContextMenu(RadPivotGridElement pivotGridElement) : base(pivotGridElement)
        {
        }
     
        protected override void OnCopyMenuItemClick(object sender, EventArgs e)
        {
            base.OnCopyMenuItemClick(sender, e);
            // the selection data is copied to Clipboard. You can get it and customize it
        }
    }

    The following threads are quite useful how to modify the clipboard data:
    https://msdn.microsoft.com/en-us/library/637ys738(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard(v=vs.110).aspx

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

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top