日期:2014-05-18  浏览次数:20845 次

分页打印问题
输出纸张有限,每页都要打表头且只打20条内容,程序要实现功能:判断医嘱内容>20条打印第一、二页,以下是原代码,新手入门请给予帮助,谢谢!
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
  //第一页
  e.Graphics.DrawString(this.textBox1.Text+"床",new Font("宋体",11,FontStyle.Bold),Brushes.Black,6,88);
  e.Graphics.DrawString("姓名:"+this.textBox2.Text,new Font("宋体",11,FontStyle.Bold),Brushes.Black,45,88);
  e.Graphics.DrawString("ID号:"+this.textBox4.Text,new Font("宋体",11,FontStyle.Bold),Brushes.Black,160,88);
  e.Graphics.DrawString(this.textBox33.Text+" 输液单",new Font("宋体",14,FontStyle.Underline),Brushes.Black,100,58);
  e.Graphics.DrawString("日期 "+this.textBox55.Text,new Font("宋体",11,FontStyle.Bold),Brushes.Black,275,88);
  e.Graphics.DrawString("医 嘱 内 容",new Font("宋体",11,FontStyle.Bold),Brushes.Black,20,108);
  Pen pen = new Pen(Color.Black,2);
  Point[] points =
  {
  new Point(0,105),
  new Point(400,105)
  };
  e.Graphics.DrawLines(pen,points);
  Point[] points1 =
  {
  new Point(0,128),
  new Point(400,128)
  };
  e.Graphics.DrawLines(pen,points1);//以上为表头
  e.Graphics.DrawString(this.textBox12.Text+" "+this.textBox13.Text+this.textBox14.Text+this.textBox207.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,135);
  e.Graphics.DrawString(this.textBox15.Text+" "+this.textBox16.Text+this.textBox17.Text+this.textBox206.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,155);
  e.Graphics.DrawString(this.textBox18.Text+" "+this.textBox19.Text+this.textBox20.Text+this.textBox205.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,175);
  e.Graphics.DrawString(this.textBox21.Text+" "+this.textBox22.Text+this.textBox23.Text+this.textBox204.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,195);
  e.Graphics.DrawString(this.textBox24.Text+" "+this.textBox25.Text+this.textBox26.Text+this.textBox203.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,215);
  e.Graphics.DrawString(this.textBox27.Text+" "+this.textBox28.Text+this.textBox29.Text+this.textBox202.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,235);
  e.Graphics.DrawString(this.textBox30.Text+" "+this.textBox31.Text+this.textBox32.Text+this.textBox201.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,255);
  e.Graphics.DrawString(this.textBox36.Text+" "+this.textBox35.Text+this.textBox34.Text+this.textBox200.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,275);
  e.Graphics.DrawString(this.textBox40.Text+" "+this.textBox39.Text+this.textBox38.Text+this.textBox199.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,295);
  e.Graphics.DrawString(this.textBox44.Text+" "+this.textBox43.Text+this.textBox42.Text+this.textBox198.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,315);
  e.Graphics.DrawString(this.textBox48.Text+" "+this.textBox47.Text+this.textBox46.Text+this.textBox197.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,335);
  e.Graphics.DrawString(this.textBox59.Text+" "+this.textBox58.Text+this.textBox56.Text+this.textBox196.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,355);
  e.Graphics.DrawString(this.textBox63.Text+" "+this.textBox62.Text+this.textBox61.Text+this.textBox195.Text,new Font("宋体",10,FontStyle.Bold),Brushes.Black,6,375);
  e.Graphics.DrawSt