在C#.net 4.0(桌面)中打印表单 [英] Printing a form in C# .net 4.0(Desktop)

查看:150
本文介绍了在C#.net 4.0(桌面)中打印表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码打印表单。

I am using the following code to print a form.

PaperSize pp = new PaperSize("MyReport", 827, 1169);
printForm1.PrinterSettings.DefaultPageSettings.PaperSize = pp;
printForm1.PrinterSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
printForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview;
printForm1.Print(this, PrintForm.PrintOption.FullWindow);



带参考


with references

using Microsoft.VisualBasic.PowerPacks.Printing;
using System.Drawing.Printing;
using System.Runtime.InteropServices;



它工作正常并打印一个空白表格。但我需要打印一个名为printForm.cs的表单,我已将其设计到我的项目中。我怎么解决这个问题?我是新打印的,请帮帮我。提前谢谢。


It's work fine and print a blank form. but I need to print a form named printForm.cs which i already designed into my project. How can I solve this? I am new in printing, please help me. Thank's in advance.

推荐答案

不要这样做!



相反,看看使用< a href =http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(v=vs.110).aspx> PrintDocument Class [ ^ ] - 它为您提供了更大的灵活性和更好的打印效果。

在页面上转储控件似乎更多的工作,但它是值得的 - 结果好多了。 br />


该链接包含一个示例。
Don't do that!

Instead, look at using the PrintDocument Class[^] - it gives you a lot greater flexibility and a better print out.
It may seem more work that just dumping controls on a page, but it is worth it - teh results are a lot better.

The link includes an example.


这篇关于在C#.net 4.0(桌面)中打印表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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