int line = 0;///i want to reset this back to 0///
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
int y = 0;
Console.WriteLine("1st " + line);
do
{
e.Graphics.DrawString(invoiceList[line], new Font("Arial", 10, FontStyle.Regular), Brushes.Black, 50, 200);
Console.WriteLine("2nd " + line);
line += 1;
Console.WriteLine("3rd " + line);
y += 1;
if (y > 0)
{
e.HasMorePages = line != invoiceList.Count();
Console.WriteLine("4th " + line);
break;
}
} while (line < invoiceList.Count());
Console.WriteLine("6th " + line);
}
如何重置變量line
?因爲當我按下從printPreviewDialog
產生的System.ArgumentOutOfRangeException
的打印按鈕時,它只是不斷加起來。編輯1: 對不起,我看起來不清楚。它的這條線e.Graphics.DrawString(invoiceList[line], new Font("Arial", 10, FontStyle.Regular), Brushes.Black, 50, 200);
這給我一個錯誤。c#do-while循環如何重置變量?
所以第一this is what happen when i press the print button
如可以從圖片「第六(line
)= 12」或索引12.
所以看到,當我從打印預覽再次按下打印按鈕打印的物理複製它會顯示this。對不起,我解釋事情真的很糟糕。
在'event'中聲明這個變量('int line = 0;')。 –