本文介绍了如何使用C#在A4纸上打印表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在A4表格中使用标题栏和控件打印表单.我尝试了很多代码,但无法获得结果.请告诉代码.
谢谢
Hi,
How to print a form with it''s title bar and controls in an A4 sheet.I have tried many codes but couldn''t get the result.Kindly tell the code.
Thank you
推荐答案
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap img = new Bitmap(this.Width, this.Height);
//define which is to print
this.DrawToBitmap(img,new Rectangle(0,0,this.Width,this.Height));
Graphics g=e.Graphics;
g.PageUnit=GraphicsUnit.Display;
g.DrawImage(img,new RectangleF(0,0,this.Width,this.Height));
}
并添加打印按钮button1->
and Add a print button button1 -->
private void button1_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
this.printForm1.Print();
这篇关于如何使用C#在A4纸上打印表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!