Saving Image from a Panel

bitmapimage, c#, visual-studio, winforms

Solution

Try using the Panel control instead (also, use the ClientSize properties and dispose of the bitmap when done):

using (Bitmap bitmap = new Bitmap(panel1.ClientSize.Width, 
                                  panel1.ClientSize.Height)) {
  panel1.DrawToBitmap(bitmap, panel1.ClientRectangle);
  bitmap.Save("C:\\" + pagAtual + ".bmp", ImageFormat.Bmp);
}

Problem

I'm trying to save a bitmap from the panel, but the saved image is with the program's bar... How can I do for save an image onyly with an specified panel? Here is my code: ``` Bitmap bitmap = new Bitmap(panel1.Width, panel1.Height); this.DrawToBitmap(bitmap, panel1.ClientRectangle); bitmap.Save("C:\\" + pagAtual + ".bmp", ImageFormat.Bmp); ```

Original source