title: How can I print the large dataGridView/Form on multiple pages?
body: <p>Just using Win Forms in C#. Created Data Grid View and added print button. Here is my code for print button. </p>
  
  <pre><code>private void toolStripButton1_Click(object sender, EventArgs e)
      {
          image = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);
          this.dataGridView1.DrawToBitmap(image, new Rectangle(new Point(), this.dataGridView1.Size));
          memStream = new System.IO.MemoryStream();
          printPDialog = new PrintPreviewDialog();
  
          try
          {
              printFont = new Font("Arial", 10);
              image.Save(memStream, System.Drawing.Imaging.ImageFormat.Bmp);
              image.Save("d:\\Adnan.bmp");
              p = new PrintDocument();
              p.PrintPage += this.p_PrintPage;
  
              this.printPDialog.Document = p;
              printPDialog.Show();
  
          }
          catch (System.Runtime.InteropServices.ExternalException ee)
          {
  
          }
  
  }
  
      private void p_PrintPage(object sender, PrintPageEventArgs e)
      {
          float linesPerPage = 0;
          float yPos = 0;
          int count = 0;
          float leftMargin = e.MarginBounds.Left;
          float topMargin = e.MarginBounds.Top;
          int? line = null;
  
          // Calculate the number of lines per page.
          linesPerPage = e.MarginBounds.Height /
             printFont.GetHeight(e.Graphics);   
          e.Graphics.DrawImage(Image.FromStream(memStream), leftMargin, topMargin);
  
      }
  
  
      private void printPDialog_FormClosed(object sender, FormClosedEventArgs e)
      {
          image.Dispose();
          memStream.Dispose();
      }
  </code></pre>
  
  <p>Problem is my DataGridView has a large list. I have DataGridView inside the FlowLayoutPanel. I tried printing FlowLayoutPanel as well as GridView but in either case the data which is obscure by a vertical scrollbar does not get printed. After spending hours online and trying VB powerpacks I am at loss what to do. </p>
  
  <p>Here is how the data looks in GridView. </p>
  
  <p><img src="https://i.stack.imgur.com/vrQid.png" alt="enter image description here"></p>