读书人

打印换页没数据

发布时间: 2013-07-04 11:45:55 作者: rapoo

打印换页,没有数据
int x, y;
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.HasMorePages = false;
y += 260;
x = 20;

for (rows = rows; rows < myds.Tables[0].Rows.Count;rows++) //我的数据有108条
{
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["DetailsID"].ToString();, new Font("宋体", 12), Brushes.Black, x, y);
x = 80;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["AreaMedian"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 180;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["LocationMedian"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 230;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["SegmentNumber"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 280;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["FaceBit"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 380;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["Department"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 480;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["SKU"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 650;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["SellingPrice"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 750;
e.Graphics.DrawString(myds.Tables[0].Rows[rows]["Num"].ToString(), new Font("宋体", 12), Brushes.Black, x, y);
x = 20;


y += 20;

int a = rows % 40;
if (a == 0 && rows != 0) //判断是否是40的倍数 如果是,则换页。也就是一页打印40行
{
e.HasMorePages = true;
num++;
rows = 40 * num;
rows++; //下一次打印从41开始
break;
}
else
{
e.HasMorePages = false;
}
}
}
现在我的数据有108条,现在有3页了。但是
只有前40条有数据,后面的就没有了数据了呢? 打印换页
[解决办法]
num是怎么来的?

读书人网 >C#

热点推荐