How do you copy the graphic contents of a panel or picturebox to the clipboard? The contents were prepared using createGraphics from System.Drawing.Graphics.
I dont have a problem posting a textbox or another control. I would like to post the entire graphic contents to the clipboard to paste in PowerPoint/Word/WordPerfect without changes in relative locations of the graphics.
Assuming youre drawing to the Image portion of the pictureBox, you could try something like this:
Code:
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
Graphics g = Graphics.FromImage(pictureBox1.Image);
g.DrawLine(Pens.Red, 0, 0, 20, 20);
g.Dispose();
Clipboard.SetDataObject(pictureBox1.Image, true);
The first line creates a new Bitmap for the Image property.
The next few lines simulate some drawing to the Image property (a simple red line in this case).
The last line saves the bitmap to the clipboard, which is what I think you were asking...?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.