M MCM Aug 24, 2007 #1 How do I capture an Image (Bitmap) of one of my controls (in a Windows Form App) and place it on the clipboard in C#? Thanks, - M
How do I capture an Image (Bitmap) of one of my controls (in a Windows Form App) and place it on the clipboard in C#? Thanks, - M
M Marc Gravell Aug 24, 2007 #2 Well, I've never had to try it, but the following seems to work: private static void CopyControl(Control target) { if (target == null) throw new ArgumentNullException("target"); using (Bitmap bmp = new Bitmap(target.Width, target.Height)) { target.DrawToBitmap(bmp, new Rectangle(new Point(0,0), target.Size)); Clipboard.SetImage(bmp); } } I stress that I don't know if there are any problems using this approach... Marc
Well, I've never had to try it, but the following seems to work: private static void CopyControl(Control target) { if (target == null) throw new ArgumentNullException("target"); using (Bitmap bmp = new Bitmap(target.Width, target.Height)) { target.DrawToBitmap(bmp, new Rectangle(new Point(0,0), target.Size)); Clipboard.SetImage(bmp); } } I stress that I don't know if there are any problems using this approach... Marc