今天做程序,遇到了一个奇怪的问题:
我用的是斑马888-TT的标签打印机,打印程序基本如下:........for (int i = 0; i < codeValList.Count;i++ )
{
string codeval = codeValList[i].ToString();
DataRow[] dr = dt.Select("C_TypeCode =" + codeval.Substring(0, 8).Trim());
this.codeType = dr[0]["C_TypeName"].ToString();//获得型号 this.codeVal = "*" + codeval + "*";//需要打印的条码(39码)
//this.codeVal = codeval ;
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
PD.AllowSomePages = true;
PD.ShowHelp = true;
PD.Document = printDoc; printDoc.Print(); }
.........
#region 打印程序
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
Font FontWorkCodeText = new Font("宋体", 6, FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)(134));
e.Graphics.DrawString(codeText, FontWorkCodeText, Brushes.Black, 10, 8); e.Graphics.DrawString(codeType, FontWorkCodeText, Brushes.Black, 60, 8); Font FontWorkCode = new Font("LikaiCode39", 15, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
e.Graphics.DrawString(codeVal, FontWorkCode, Brushes.Black, 10, 20); }
#endregion在红色字的地方设置断点后,逐次打印从codeValList中获得的数据,顺序没有问题。
取消断点后,连续打印,则没有按照codeValList数组中的数据打印,出现错大,多打,漏打的想象。向高手求教:是程序问题,还是打印机的某些设置不对,例如打印速度等。
解决马上给分。
我用的是斑马888-TT的标签打印机,打印程序基本如下:........for (int i = 0; i < codeValList.Count;i++ )
{
string codeval = codeValList[i].ToString();
DataRow[] dr = dt.Select("C_TypeCode =" + codeval.Substring(0, 8).Trim());
this.codeType = dr[0]["C_TypeName"].ToString();//获得型号 this.codeVal = "*" + codeval + "*";//需要打印的条码(39码)
//this.codeVal = codeval ;
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
PD.AllowSomePages = true;
PD.ShowHelp = true;
PD.Document = printDoc; printDoc.Print(); }
.........
#region 打印程序
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
Font FontWorkCodeText = new Font("宋体", 6, FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)(134));
e.Graphics.DrawString(codeText, FontWorkCodeText, Brushes.Black, 10, 8); e.Graphics.DrawString(codeType, FontWorkCodeText, Brushes.Black, 60, 8); Font FontWorkCode = new Font("LikaiCode39", 15, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
e.Graphics.DrawString(codeVal, FontWorkCode, Brushes.Black, 10, 20); }
#endregion在红色字的地方设置断点后,逐次打印从codeValList中获得的数据,顺序没有问题。
取消断点后,连续打印,则没有按照codeValList数组中的数据打印,出现错大,多打,漏打的想象。向高手求教:是程序问题,还是打印机的某些设置不对,例如打印速度等。
解决马上给分。
可能调用Print方法后新开了一个线程。你设断点的时候,有足够的时间够打印。连续打印需要线程同步。