Copy drawn image to clipboard

Posted on 2009-04-20
Last Modified: 2012-05-06
I am drawing an image onto a picturebox which I then need to copy to the clipboard.

I have done this before with groups of controls using:

Dim bmp As New Bitmap(icontrolwidth, icontrolheight)
Me.pic1.DrawToBitmap(bmp, New Rectangle(icontrolleft, icontroltop, icontrolwidth, icontrolheight))

but since I am drawing this myself (using Graphics.FillPolygon) it does not put any data in the clipboard.

How can I acheive this (which will be pasted into MS Office document after this).
Question by:CarlPritchard
    LVL 39

    Accepted Solution

    If I make an image myself, the following works for me:

    Bitmap bmpTest = new Bitmap(picSourceSmall.Image);
    Graphics graphTest = Graphics.FromImage(bmpTest);
    graphTest.DrawString("HELLO WORLD", 
        new SolidBrush(Color.Black), 
        new PointF(10.0F, 10.0F));
    picSourceSmall.Image = bmpTest;

    Open in new window

    LVL 39

    Expert Comment

    oops, that was C# in a VB thread. Can you read it or do you need me to transform it to VB?
    LVL 6

    Author Comment

    No - was able to interpret that and make it work (thanks).

    The image box does not start with an image so I create a new  bitmap to feed to the graphics object. The problem with this is that the background is grey (the image control has white as a background but guess this is not relevant). I have worked around this by first drawing a white filled rectangle but is there a better way

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now