求助,c# winfrom用HasmorePages数组分页问题!急~~~~

blueboy2005 2010-01-28 03:50:40
private void button1_Click_1(object sender, EventArgs e)//按钮1打印预览
{

this.printPreviewDialog1.ShowDialog();
}

private void button3_Click(object sender, EventArgs e)//按钮3打印
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
this.printDocument1.Print();
}

private void button2_Click_1(object sender, EventArgs e)//按钮2打印设置
{
this.pageSetupDialog1.ShowDialog();

}

private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{

Font font = new Font("Tahoma", 8, FontStyle.Regular);//设置数据字体1
Font font1 = new Font("Tahoma", 9, FontStyle.Bold);//设置数据字体2
Font font2 = new Font("Tahoma", 18, FontStyle.Regular);//设置标题字体
Brush bru = Brushes.Black;
Pen pen = new Pen(bru);
pen.Width = 1;
//设置各边距
int nLeft = this.pageSetupDialog1.PageSettings.Margins.Left;
int nTop = this.pageSetupDialog1.PageSettings.Margins.Top;
int nRight = this.pageSetupDialog1.PageSettings.Margins.Right;
int nBottom = this.pageSetupDialog1.PageSettings.Margins.Bottom;
int nWidth = this.pageSetupDialog1.PageSettings.PaperSize.Width-nRight-nLeft;
int nHeight = this.pageSetupDialog1.PageSettings.PaperSize.Height-nTop-nBottom;
//打印各边距
e.Graphics.DrawLine(pen, nLeft-60, nTop-40, nLeft-60, nTop + nHeight+40);
e.Graphics.DrawLine(pen, nLeft+nWidth+60, nTop-40, nLeft+nWidth+60, nTop + nHeight+40);
e.Graphics.DrawLine(pen, nLeft-60, nTop-40, nLeft+nWidth+60, nTop-40);
e.Graphics.DrawLine(pen, nLeft-60, nTop+nHeight+40, nLeft + nWidth+60, nTop+nHeight+40);
e.Graphics.DrawString("制表人:", font1, bru, nLeft - 60, nTop + nHeight + 60);
e.Graphics.DrawString("复 核:", font1, bru, nLeft+300, nTop + nHeight + 60);

//在离左边距20,右边距20的位置打印haha xixi
e.Graphics.DrawString("卫生材料入库单", font2, bru, nLeft + 60, nTop - 80);//打印标题
double heji = 0;
for (int j = 1; j < leng; j++)
{
heji = heji + Convert.ToDouble(rukusum[j]);
}
int i = 0;
while (i < leng)
{
e.Graphics.DrawString(name[i], font, bru, nLeft - 40, nTop - 30 + i * 30);
e.Graphics.DrawString(guig[i], font, bru, nLeft + 100, nTop - 30 + i * 30);
e.Graphics.DrawString(danwei[i], font, bru, nLeft + 150, nTop - 30 + i * 30);
e.Graphics.DrawString(shuliang[i], font, bru, nLeft + 200, nTop - 30 + i * 30);
e.Graphics.DrawString(danja[i], font, bru, nLeft + 250, nTop - 30 + i * 30);
e.Graphics.DrawString(rukusum[i], font, bru, nLeft + 400, nTop - 30 + i * 30);
e.Graphics.DrawString(cgdanwei[i], font, bru, nLeft + 500, nTop - 30 + i * 30);
e.Graphics.DrawString(inttime[i], font, bru, nLeft + 600, nTop - 30 + i * 30);
if (i == 0)
{
e.Graphics.DrawLine(pen, nLeft - 60, nTop - 15, nLeft + nWidth + 60, nLeft - 15);
}
else if (i == leng - 1)
{
e.Graphics.DrawString("合 计", font1, bru, nLeft - 40, nTop + i * 30);
e.Graphics.DrawString(heji.ToString(), font1, bru, nLeft + 400, nTop + i * 30);
}
i++;
}

}


我想请问,如何用Hasmorepages以上打印数组的结果分页显示,谢谢!!!
...全文
170 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
清风一笑007 2011-02-22
  • 打赏
  • 举报
回复
你的这个问题解决了吗?
blueboy2005 2010-01-29
  • 打赏
  • 举报
回复
还有知道的吗?
blueboy2005 2010-01-29
  • 打赏
  • 举报
回复
大家帮帮忙啊
blueboy2005 2010-01-28
  • 打赏
  • 举报
回复
我现在不知道我的while循环语句中打印数组的内容如何分页打印出来,比如我每页只打20打记录,那我while循环里面如何去控制呢,在while循环语句中加上
if(i>20)
{
e.hasmorepages=true;
}
好像不可以,总是循环出许多页一样的内容.
wuyq11 2010-01-28
  • 打赏
  • 举报
回复
blueboy2005 2010-01-28
  • 打赏
  • 举报
回复
自己顶一下
blueboy2005 2010-01-28
  • 打赏
  • 举报
回复
有知道的吗?帮帮忙吧
blueboy2005 2010-01-28
  • 打赏
  • 举报
回复
e.HasmorePages=true;
不知道?
Justin-Liu 2010-01-28
  • 打赏
  • 举报
回复
HasmorePages? what?

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧