首页新闻找找看学习计划

.net winform 多页打印 打印预览正常 但再打印的时候就只有一个空白页

0
悬赏园豆:10 [已关闭问题] 关闭于 2009-05-25 21:33

.net winform 多页打印

打印预览正常 但再打印的时候就只有一个空白页 ,据说是重新设置打印页码

是在哪里设置啊?找了半天也没找到

 

这里是绘制预览代码 请高手指教啊

void Print_AllMessage(object sender, PrintPageEventArgs e)
        {
            // 公共设置部分 字体 ,填充色 打印区域
            Font drawFont = new Font("Arial", 10);

            SolidBrush drawBrush = new SolidBrush(Color.Black);  //打印颜色

            float x = this.px;  //坐標x

            float y = this.py;  //坐標y

            float width = 408;

            float height = 282;

            RectangleF drawRect;

            //循环部分,打印多页
            for (int i = rowi; i < this.mymails.Count; i++)
                //for (int i = rowi; i < this.mymails.Count; rowi++, i++)
            {
                str = "";
                str += "\n  邮编:" + this.mymails[rowi].postNum.ToString().Trim();
                str += "\n\n           " + this.mymails[rowi].address.ToString().Trim();
                str += "\n\n\n           " + this.mymails[rowi].companyName.ToString().Trim();
                str += "\n\n\n                                            " + this.mymails[rowi].personName.ToString().Trim() + " (收)";
                str += "\n\n\n           " + this.tbx_Address.Text.Trim();
                str += "\n\n                                                                             邮编:" + this.tbx_PostNum.Text.Trim();
               
                drawRect = new RectangleF(x, y, width, height);  //一个矩形框的实现,文字将来打印在这个矩形框中

                Pen blackPen = new Pen(Color.Black);
                e.Graphics.DrawRectangle(blackPen, x, y, width, height);  //绘制一个矩形框

                e.Graphics.DrawString(str, drawFont, drawBrush, drawRect);  //在矩形框中绘制文本

                if ((rowi + 1) % this.PageSize == 0 && rowi < (this.mymails.Count - 1))
                {
                    //rowi++;
                    x = 2;
                    y = 0;
                    //e.HasMorePages = true;
                    //break;
                }
                else
                {
                    if (rowi % 2 == 0)
                    {
                        x += width + 3;
                    }
                    else
                    {
                        x = 2;
                        y += height + 10;
                    }
                    //e.HasMorePages = false;
                }


                if ((rowi + 1) % this.PageSize == 0 && rowi < (this.mymails.Count - 1))
                {
                    rowi++;
                    e.HasMorePages = true;
                    break;
                }
                else
                {
                    rowi++;
                    e.HasMorePages = false;
                }
            }

        }

 

阳光有约的主页 阳光有约 | 初学一级 | 园豆:95
提问于:2009-05-19 16:17
< >
分享
所有回答(1)
0

同问,前些天打印都很正常,后面不知道改了什么,现在发现打印预览里面再点击打印按钮就打印出来空白页了。

nyxuem | 园豆:204 (菜鸟二级) | 2014-04-02 13:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册