I would like to print more pages using c# . in the function printDocument1_PrintPage which prints the document i have:
int values = 0;
foreach (DataRow row in rows.Rows)
values++;
if (values > 48)
{
e.HasMorePages = true;
values = 0;
}
else
{
e.HasMorePages = false;
}
The problem is that it keeps printing pages without stop. How can i keep track of how many rows to print on page ?
That cannot work, it starts values at 0 for every page. So it never stops. You’ll need to move the variable outside of the PrintPage method. You’ll also need to implement BeginPrint so you’ll start back at 0. The foreach() is trouble as well, you don’t want to start back at beginning for every page. So rewrite it similar to this: