求助,c# winfrom用HasmorePages数组分页问题!急~~~~
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以上打印数组的结果分页显示,谢谢!!! --------------------编程问答-------------------- HasmorePages? what? --------------------编程问答-------------------- e.HasmorePages=true;
不知道? --------------------编程问答-------------------- 有知道的吗?帮帮忙吧 --------------------编程问答-------------------- 自己顶一下
--------------------编程问答-------------------- 多页打印 --------------------编程问答-------------------- 我现在不知道我的while循环语句中打印数组的内容如何分页打印出来,比如我每页只打20打记录,那我while循环里面如何去控制呢,在while循环语句中加上
if(i>20)
{
e.hasmorepages=true;
}
好像不可以,总是循环出许多页一样的内容. --------------------编程问答-------------------- 还有知道的吗? --------------------编程问答-------------------- 大家帮帮忙啊 --------------------编程问答-------------------- 你的这个问题解决了吗?
补充:.NET技术 , C#