将完整的Windows表单发送到打印机. [英] Sending complete windows form to printer.

查看:95
本文介绍了将完整的Windows表单发送到打印机.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将完整的Windows表单发送给打印机以在屏幕上显示其所有内容(带有文本和图像的控件)吗?如果是,请为其提供代码.

Can I send complete windows form to printer to print with all its contents (controls with text and images) displaying on screen? If yes, please provide code for it.

推荐答案

http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714 [ ^ ]
不使用API​​打印Windows窗体 [ Google [ ^ ]还有更多.
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714[^]
Print Windows Forms w/o using API[^]

Google[^] has many more.




Prera​​ks的回答非常好,但是CP文章对可打印控件有一些限制.只是添加一种简单的方法.您可以使用以下代码从任何控件(例如您的表单)创建位图:
Hi,

Preraks answer is very good, but the CP article has some limitations about the controls that can be printed. Just to add one simple way. You can create a bitmap from any control (e.g. your form) by using this code:
Bitmap bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, Rectangle.FromLTRB(0, 0, this.Width, this.Height));
//bmp.Save("C:\\Test.bmp"); // save it to a file or send it to the printer


创建位图后,您可以使用它进行任何操作-因此将其发送到打印机应该非常容易.
希望对您有所帮助!


After creating the bitmap you can do anything you want with it - so it should be quite easy to send it to the printer.
I hope it helps!


这篇关于将完整的Windows表单发送到打印机.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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