Copy grid

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

    Posted 10 Oct 2016 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 | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3378 posts

    Posted 12 Oct 2016 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. Deepak
    Deepak avatar
    27 posts
    Member since:
    May 2016

    Posted 25 May 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hello,

    I used GetDataObject to see data inside clipboard but its not working. Also if i will get data how i will column headers and Row headers to it.

     

    IDataObject iData = Clipboard.GetDataObject();

     

     

    Regards,

    Deepak

  4. Deepak
    Deepak avatar
    27 posts
    Member since:
    May 2016

    Posted 26 May 2017 in reply to Deepak Link to this post

    Hello,

    Any solution for my above queries ?

     

    Regards,

    Deepak

  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3378 posts

    Posted 26 May 2017 Link to this post

    Hello Deepak, 

    Thank you for writing.  

    In order to get the Clipboard text, feel free to use the Clipboard.GetText method. Additional information is available in the following MSDN thread: https://social.msdn.microsoft.com/Forums/windows/en-US/8c677273-77bf-4423-a799-528e3aed837e/c-paste-from-clipboard?forum=winforms

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

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Amit
    Amit avatar
    4 posts
    Member since:
    Mar 2018

    Posted 4 days and 23 hours ago in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Dear Dess,

    var txtmsg2 = Clipboard.GetText();

    Only get the value of cell we are selected to copy. We want row and column header name with cell value.

    How can we get that?

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3378 posts

    Posted 3 days and 6 hours ago Link to this post

    Hello, Amit,      

    The Clipboard.GetText method returns only the text that is stored in the global Clipboard object. The default copy behavior internally uses the  Clipboard.SetDataObject method passing a newly created DataObject

    If you want to extract the row/column of the copied cells, note that the CellFormatting event is fired for a special type of cell element (FormatCellElement). Thus, you can extract its row/column:

            private void radPivotGrid1_CellFormatting(object sender, PivotCellEventArgs e)
            {
                if (e.CellElement.GetType().ToString() == "Telerik.WinControls.UI.FormatCellElement")
                {
                    Console.WriteLine(e.CellElement.Row);
                    Console.WriteLine(e.CellElement.Column);
                }
            }
    I hope this information helps.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top