private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
int a = 0;
for (int i = 0; i < DGV_source.RowCount; i++)
{
if (Convert.ToBoolean(DGV_source.Rows[i].Cells[0].Value) != false)
{
e.HasMorePages = true;
ID = DGV_source.Rows[i].Cells[1].Value.ToString();
name = DGV_source.Rows[i].Cells[2].Value.ToString();
no = DGV_source.Rows[i].Cells[3].Value.ToString();
while (ID.Length < 7)
{
ID = ID.Insert(1, "0");
}
ID = ID.Replace("P", "");
if (no == "1") no = ""; e.Graphics.DrawString(ID, new Font("Arial", 40, FontStyle.Bold), Brushes.Black, IDx, a * e.PageBounds.Height + IDy);
e.Graphics.DrawString(name, new Font("Arial", 40, FontStyle.Bold), Brushes.Black, Namex, a * e.PageBounds.Height + Namey);
e.Graphics.DrawString(no, new Font("Arial", 40, FontStyle.Bold), Brushes.Black, Nox, a * e.PageBounds.Height + Noy);
a++;
} }
e.HasMorePages = false;
}
catch (Exception err) { MessageBox.Show(err.Message); }
}只能打印第一页,其他都打印不出,请问代码有什么问题呢?
{
try
{
int a = 0;
for (int i = 0; i < DGV_source.RowCount; i++)
{
if (Convert.ToBoolean(DGV_source.Rows[i].Cells[0].Value) != false)
{
e.HasMorePages = true;
ID = DGV_source.Rows[i].Cells[1].Value.ToString();
name = DGV_source.Rows[i].Cells[2].Value.ToString();
no = DGV_source.Rows[i].Cells[3].Value.ToString();
while (ID.Length < 7)
{
ID = ID.Insert(1, "0");
}
ID = ID.Replace("P", "");
if (no == "1") no = ""; e.Graphics.DrawString(ID, new Font("Arial", 40, FontStyle.Bold), Brushes.Black, IDx, a * e.PageBounds.Height + IDy);
e.Graphics.DrawString(name, new Font("Arial", 40, FontStyle.Bold), Brushes.Black, Namex, a * e.PageBounds.Height + Namey);
e.Graphics.DrawString(no, new Font("Arial", 40, FontStyle.Bold), Brushes.Black, Nox, a * e.PageBounds.Height + Noy);
a++;
} }
e.HasMorePages = false;
}
catch (Exception err) { MessageBox.Show(err.Message); }
}只能打印第一页,其他都打印不出,请问代码有什么问题呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货