title: Printing DataGridView
body: <p>I have set up a form, where I have a DataGridView with bookings, currently I can print the DataGridView but only what is on display, so any data that is only visible by scrolling down is not printed. </p>
  
  <p>How do I alter my code so when i click the print button everything (including data that is viewed by scrolling) is printed to the page?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace project
  {
      public partial class frmViewBookings : Form
      {
          public frmViewBookings()
          {
              InitializeComponent();
          }
  
          private void btnClose_Click(object sender, EventArgs e)
          {
              Form3 mainpage = new Form3();
              mainpage.Show();
              this.Close();
          }
  
          private void frmViewBookings_Load(object sender, EventArgs e)
          {
              // TODO: This line of code loads data into the 'usersDataSet1.Booking' table. You can move, or remove it, as needed.
              this.bookingTableAdapter.Fill(this.usersDataSet1.Booking);    
          }
  
          private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
          {
              Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);
              this.dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));
              e.Graphics.DrawImage(bm, 0, 0);
          } 
  
          private void btnPrint_Click(object sender, EventArgs e)
          {
              printDocument1.Print();
          }
      }
  }
  </code></pre>