title: How can I print a TabControl page in Winforms?
body: <p>I'm trying to print the selected page of a winforms tabcontrol, but no matter what I do all I get is a blank page.</p>
  
  <p>I have this code to capture and print a screenshot of a windows form using a PrintDocument control; I'd like to do something similar to this.</p>
  
  <pre><code>    private void CaptureScreen()
      {
          Graphics myGraphics = this.CreateGraphics();
          Size s = this.Size;
          memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
          Graphics memoryGraphics = Graphics.FromImage(memoryImage);
          memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
      }
  
      private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
      {
          Bitmap newImage = new Bitmap(memoryImage, new Size(Convert.ToInt32(memoryImage.Width / 1.25), Convert.ToInt32(memoryImage.Height / 1.25)));
          newImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
          e.Graphics.DrawImage(newImage, 0, 0);
      }
  
      private void printBtn_Click(object sender, EventArgs e)
      {
          PrintDialog myPrintDialog = new PrintDialog();
          if (myPrintDialog.ShowDialog() == DialogResult.OK)
          {
              CaptureScreen();
              printDocument1.Print();
          }
      }  
  </code></pre>
  
  <p>I have tried changing the object referenced in the CaptureScreen function to the tab page, as opposed to the overall windows form; I've tried figuring out how to use the PrintDialog object's "PrintVisual" function, but that only seems to work in WPF projects, which this isn't. Does anyone know how to make this work?</p>