title: C# Save all of scrollable Panel as Image
body: <p>I'm trying to save all of a panel to a JPG, I already asked this question but the answer wasn;t what I was looking for. The problem is that the panel has a scrollbar (not enough space for all elements) but it doesn't print what is at the bottom of the panel, only visible elements.</p>
  
  <pre><code>public void DrawControl(Control control,Bitmap bitmap)
  {
      control.DrawToBitmap(bitmap,control.Bounds);
      foreach (Control childControl in control.Controls)
      {
          DrawControl(childControl,bitmap);
      }
  }
  
  public void SaveBitmap()
  {
      Bitmap bmp = new Bitmap(this.panel1.Width, this.panel.Height);
  
      this.panel.DrawToBitmap(bmp, new Rectangle(0, 0, this.panel.Width, this.panel.Height));
      foreach (Control control in panel1.Controls)
      {
          DrawControl(control, bmp);
      }
  
      bmp.Save("d:\\panel.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
  }
  </code></pre>