I am trying to Printing Datagridview by making bitmap image , Its working nicely but it printing only in 1 page to print .
Here is DataGirdView Image :
Print Preview Image :
Here in print-Preview not having total rows to the last as of DataGridView row and only having 1 page
Code of Printing :
private void Btn_Print_Click(object sender, EventArgs e) { int height = DGV.Height; DGV.Height = DGV.RowCount * DGV.RowTemplate.Height * 2; bmp = new Bitmap(DGV.Width, DGV.Height); DGV.DrawToBitmap(bmp, new Rectangle(0, 0, DGV.Width, DGV.Height)); DGV.Height = height; printPreviewDialog1.ShowDialog(); } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawImage(bmp, 0, 0); } Why not printing data in more than 1 page ? Is there any wrong in code ? Please give suggestion
Thank you .
1 Answer
It's not the easiest thing to print multiple pages from a DataGridView so I recommend you to use one of the existing code samples. Here's couple good ones which are easy to use and can print multiple pages:
Some more examples are available from this SO question:
Best way to print a datagridview with all rows and all columns?
