如何在.net中打印Windows窗体 [英] How to print the windows form in .net

查看:92
本文介绍了如何在.net中打印Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何打印Windows窗体.我们也可以将其打印为彩色.并且也有作为pdf打印的选项.如果有人知道,请告诉.

How to print the windows form. Also can we print as color. And also is there option as print as pdf. If any one know please tell.

推荐答案

如果要打印整个表单,则可以使用Visual Basic PowerPacks工具箱中的PrintForm控件.
相同 http://www.microsoft.com/download/zh-CN/details的链接.aspx?displaylang = en& id = 25169 [
if you want to print entire form then you can use PrintForm control from Visual Basic PowerPacks toolbox.

link for same http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=25169[^]


请检查此链接以供参考
http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714 [
Hi check this link for reference
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714[^]

hope it helps


查看以下代码:
protected void btnPrint_Click(object sender, EventArgs e)
{
	PrintDocument pd = new PrintDocument();
	pd.PrintPage += new PrintPageEventHandler(GetImage);
	pd.Print();      
}
void GetImage(object o, PrintPageEventArgs e)
{
	int x = SystemInformation.WorkingArea.X;
	int y = SystemInformation.WorkingArea.Y;
	int width = this.Width;
	int height = this.Height; 
	Rectangle bounds = new Rectangle(x, y, width, height); 
	Bitmap img = new Bitmap(width, height); 
	this.DrawToBitmap(img, bounds);
	Point p = new Point(100, 100);
	e.Graphics.DrawImage(img, p);    
 }


这篇关于如何在.net中打印Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆