Copy to clipboard

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

    Posted 09 Oct Link to this post

    Hi.

    I want to put a button on the form that would copy the chart to the clipboard, so that I can paste it to MS Office apps.

    I know there is an export function, but is there a way to do a copy to clipboard?

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 11 Oct Link to this post

    Hello Artemis,

    Thank you for writing.  

    The possible solution that I can suggest is to export RadChartView to an image and set this image to Clipboard. The following help article is quite useful about the export functionality: http://docs.telerik.com/devtools/winforms/chartview/features/export

    You can refer to the following stackOverflow thread where it is discussed how to set an image to Clipboard: http://stackoverflow.com/questions/16964152/how-do-i-put-an-image-on-the-clipboard

    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
  4. Artemis
    Artemis avatar
    5 posts
    Member since:
    Jul 2015

    Posted 11 Oct Link to this post

    Hi Dess.

    I have been able to export the image to a stream using the following code:

     Dim ms As New System.IO.MemoryStream
     Me.RadChartView1.ExportToImage(ms, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Jpeg)

    However, the code does not work for emf image format.

    If I use the code:

     Dim ms As New System.IO.MemoryStream
    Me.RadChartView1.ExportToImage(ms, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Emf)

    I get the following error:

    System.ArgumentNullException: Value cannot be null.

    Parameter name: encoder 

    I get the same error when I try to export to file in emf format:

     Me.RadChartView1.ExportToImage(dialog.FileName, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Emf)

     

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 13 Oct Link to this post

    Hello Artemis, 

    Thank you for writing back. 

    The ExportToImage method tries to save a Bitmap to the specified format. However, it seems that saving emf files should be handled in a different way. Please refer to the following stackOverflow threads: 

    http://stackoverflow.com/questions/152729/gdi-c-how-to-save-an-image-as-emf
    http://stackoverflow.com/questions/5270763/convert-an-image-into-wmf-with-net

    I have logged it in our feedback portal and I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to use one of the other ImageFormats.

    I hope this information helps. If you have any additional questions, please let me know.

    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.
Back to Top