学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

richTextBox控件打印小票

richTextBox控件打印小票

private void MyPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ev)
        {
  float linesPerPage = 0 ;
  float yPosition = 0 ;
  int count = 0 ;
  float leftMargin = ev.MarginBounds.Left ;
  float topMargin = ev.MarginBounds.Top ;
  string line = null ;
  Font printFont = richTextBoxXs.Font;
  SolidBrush myBrush = new SolidBrush ( Color.Black ) ;
  //计算每一页打印多少行
  linesPerPage = ev.MarginBounds.Height / printFont.GetHeight ( ev.Graphics ) ;
  //重复使用StringReader对象 ,打印出richTextBox1中的所有内容
  while ( count < linesPerPage && ( ( line = myReader.ReadLine ( ) ) != null ) )
  {
  // 计算出要打印的下一行所基于页面的位置
  yPosition = topMargin + ( count * printFont.GetHeight ( ev.Graphics ) ) ;
  // 打印出richTextBox1中的下一行内容
  ev.Graphics.DrawString ( line , printFont , myBrush , leftMargin , yPosition , new StringFormat ( ) ) ;
  count++ ;
  }
  // 判断如果还要下一页,则继续打印 BBS.bitsCN.com网管论坛
  if ( line != null )
  ev.HasMorePages = true ;
  else
  ev.HasMorePages = false ;
  myBrush.Dispose ( ) ;
  }

上面这段代码在我们自己的打印机(不是小票机,一般的打印机)上能正常打印小票, 可是在客户的小票机(小票机)上却不能打印小票?
请高手指点?????

TOP

发新话题