Results 1 to 9 of 9

Thread: [RESOLVED] Can I copy chart control graph to clipboard?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    135

    Resolved [RESOLVED] Can I copy chart control graph to clipboard?

    Hi,

    I have a chart control (chtReport) and once it generates the graph, I'd like to copy the graph to the clipboard using a form button (see attached).

    I can only find examples of copying plain text to the clipboard but nothing for a report.

    Cheers,
    J

    Name:  ChartToClipboard.jpg
Views: 1612
Size:  15.1 KB

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Can I copy chart control graph to clipboard?

    Would an image (of the chart) be ok?
    I think that's the best you can hope for.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    135

    Re: Can I copy chart control graph to clipboard?

    Hi mate,

    Many thanks for your reply!

    Yes, I suspect that would be more than fine! I've been looking at an example here:

    Can you please tell me what I should be searching for? I take it (as per the link above) I can do something with the image returned value from the GetChartImage function?

    Cheers,
    J

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Can I copy chart control graph to clipboard?

    To save to the clipboard as an image...

    Code:
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        'save image
        Dim img As New Bitmap(chtReport.Width, chtReport.Height)
        Dim gr As Graphics = Graphics.FromImage(img)
        gr.Clear(Color.White)
        chtReport.Printing.PrintPaint(gr, New Rectangle(Point.Empty, chtReport.Size))
        Clipboard.SetImage(img)
    End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    135

    Re: Can I copy chart control graph to clipboard?

    Thanks, Paul!

    Worked a treat my friend. You're a legend

    Many thanks,
    J

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: [RESOLVED] Can I copy chart control graph to clipboard?

    I'm assuming it's a System.Windows.Forms.DataVisualization.Charting.Chart

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    135

    Re: [RESOLVED] Can I copy chart control graph to clipboard?

    yip

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: [RESOLVED] Can I copy chart control graph to clipboard?

    Our posts crossed over there. But all is well that ends well.

  9. #9
    New Member
    Join Date
    May 2020
    Posts
    1

    Re: Can I copy chart control graph to clipboard?

    perfect!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width