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以上打印数组的结果分页显示,谢谢!!!
{ 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以上打印数组的结果分页显示,谢谢!!!
解决方案 »
- C# WebBrowser载入网页问题
- C# 导出 Excel
- 数值转换成数组
- [求助]"=="与Equals
- 如何为listview的列添加图片
- 最后3000分!webform + web service + winform之间的通讯
- 将“按钮(button)”做成“自定义控件”,并继承“按钮类”的属性
- 各位曾使用过delphi的朋友请进。。。thanks
- 火了!为什么panel.AutoScrollMagin和AutoScrollMinSize不能动态设置!
- 各位大虾,你们用什么打包软件打包 vc
- dropdownlist的问题
- 事件A动态生成了checkboxlist控件,事件B对生成的checkboxlist进行了勾选和取消操作,并想提交勾选的结果。
不知道?
if(i>20)
{
e.hasmorepages=true;
}
好像不可以,总是循环出许多页一样的内容.