前天一个朋友托我帮他做一个连续套打的,就是有一大对证书,要能一键搞定。参考了CSDN里的一篇文章,和我们英明的大雨同志套打源码的启发现改如下:
1
// The PrintPage event is raised for each page to be printed.
2
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
3
{
4
int n=1;
5
String drawString="";
6
if(this.printDS.Tables.Count<=0)
7
{
8
//如果该表格为0 则从数据源复制表格
9
this.printDS=ds.Copy();
10
}
11
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 相关源码如下: /Files/slave2/PointPrint.rar
for(int j=0;j
{
for(int i=1;i
{
DataRow row=this.printDS.Tables[0].Rows[j];
// Create string to draw.
drawString = this.printDS.Tables[0].Rows[j][i].ToString();
// Create font and brush.
//Font drawFont = new Font("宋体", 14);
Font drawFont=new Font(GetString("PointFont","family"),float.Parse(GetString("PointFont","size")));
SolidBrush drawBrush = new SolidBrush(Color.Black);
// Create point for upper-left corner of drawing.
string tmp="Point"+i.ToString();
float x = this.GetXPoint(tmp);
float y = this.GetYPoint(tmp);
// Set format of string.
StringFormat drawFormat = new StringFormat();
//drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;
// Draw string to screen.
ev.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
}
//去掉已打印的
n++;
this.printDS.Tables[0].Rows.RemoveAt(j);
// j--;

}





//判定是否已经打印完
if(this.printDS.Tables[0].Rows.Count>0)
{
ev.HasMorePages=true;
}
else
{
//this.printDS.Tables[0].Rows.RemoveAt(this.printDS.Tables[0].Rows.Count);
//删除该表格,如果不删除的话,或在打印到最后一行的时候报错,当然不会显示,但会影响程序效率
this.printDS.Tables.RemoveAt(0);
ev.HasMorePages=false;
}

}

