I have datagridview in a form and it has multiple rows in it. And I have a following code
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
float i = 290;
int count = 1;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
e.Graphics.DrawString(count.ToString(), new Font("Times New Roman", 10), new SolidBrush(Color.Black), 13.0F, i);
e.Graphics.DrawString(Convert.ToString(row.Cells[0].Value), new Font("Times New Roman", 10), new SolidBrush(Color.Black), 70.0F, i);
e.Graphics.DrawString(Convert.ToString(row.Cells[1].Value), new Font("Times New Roman", 10), new SolidBrush(Color.Black), 185.0F, i);
e.Graphics.DrawString(Convert.ToString(row.Cells[2].Value), new Font("Times New Roman", 10), new SolidBrush(Color.Black), 275.0F, i);
e.Graphics.DrawString(Convert.ToString(row.Cells[3].Value), new Font("Times New Roman", 10), new SolidBrush(Color.Black),650.0F, i);
e.Graphics.DrawString(Convert.ToString(row.Cells[4].Value), new Font("Times New Roman", 10), new SolidBrush(Color.Black), 730.0F, i);
i = i + 13;
count++;
}
e.Graphics.DrawString("Total Quantity", new Font("Constantia", 15, FontStyle.Bold), new SolidBrush(Color.Black), 13.0F, i + 15);
e.Graphics.DrawString("Total Amount", new Font("Constantia", 15, FontStyle.Bold), new SolidBrush(Color.Black), 550.0F, i + 15);
e.Graphics.DrawString(label10.Text, new Font("Times New Roman", 15, FontStyle.Bold), new SolidBrush(Color.Black), 730.0F, i+15);
e.Graphics.DrawString(label9.Text, new Font("Times New Roman", 15, FontStyle.Bold), new SolidBrush(Color.Black), 180.0F, i + 15);
}
This code prints fine for 1 page. But after that, the remaining contents doesn't get print.
So if someone can help me with the code that I can use to print all the content from datagridview I shall be highly grateful.
Thanks in advance.