//PrintDocument对象的打印事件
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString("成绩单",new Font("宋体",20,FontStyle.Bold),Brushes.Black,350,100);
e.Graphics.DrawLine(Pens.Black,new Point(20,160),new Point(e.PageBounds.Width-20,160));
e.Graphics.DrawString("学号:",new Font("宋体",10,FontStyle.Regular),Brushes.Black,30,190);
e.Graphics.DrawString(frmLogin.uIds,new Font("宋体",10,FontStyle.Regular),Brushes.Black,80,190);
e.Graphics.DrawString("姓名:",new Font("宋体",10,FontStyle.Regular),Brushes.Black,230,190);
e.Graphics.DrawString(frmLogin.uName,new Font("宋体",10,FontStyle.Regular),Brushes.Black,280,190);
e.Graphics.DrawLine(Pens.Black,new Point(20,220),new Point(e.PageBounds.Width-20,220));
e.Graphics.DrawString("课程编号",new Font("宋体",10,FontStyle.Regular),Brushes.Black,30,250);
e.Graphics.DrawString("课程名称",new Font("宋体",10,FontStyle.Regular),Brushes.Black,180,250);
e.Graphics.DrawString("分数",new Font("宋体",10,FontStyle.Regular),Brushes.Black,400,250);
e.Graphics.DrawString("考试次数",new Font("宋体",10,FontStyle.Regular),Brushes.Black,480,250);
e.Graphics.DrawString("是否补考",new Font("宋体",10,FontStyle.Regular),Brushes.Black,560,250);
float height=280; //纵坐标
int aa=0; //记录每一页的显示数量
while(pagecount<count)
{
DataRow r=this.fraction.tbl.Rows[pagecount];
e.Graphics.DrawString(r[0].ToString(),new Font("宋体",10,FontStyle.Regular),Brushes.Black,30,height);
e.Graphics.DrawString(r[1].ToString(),new Font("宋体",10,FontStyle.Regular),Brushes.Black,180,height);
e.Graphics.DrawString(r[2].ToString(),new Font("宋体",10,FontStyle.Regular),Brushes.Black,400,height);
e.Graphics.DrawString(r[3].ToString(),new Font("宋体",10,FontStyle.Regular),Brushes.Black,480,height);
e.Graphics.DrawString(r[4].ToString(),new Font("宋体",10,FontStyle.Regular),Brushes.Black,560,height);
height+=30;
pagecount++;
aa++;
//大于25行后显示新页
if(aa>25)
{
e.HasMorePages=true;
break;
}
}
}