打印Windows表单 [英] Printing Windows Form

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

问题描述

我有一个Windows窗体.表单包含许多Windows控件,例如标签,文本框,组合框等.我想打印包含所有内容的整个表单.所以,请帮助我,如何解决此问题.

I have a Windows form. the form contains so many windows controls such as label, textbox, combo box, etc. i want to print whole form with all contents. so, please help me, how to solve this problems.

推荐答案

尝试
不使用API​​打印Windows窗体 [ http://www.c-sharpcorner.com/UploadFile/srajlaxmi/PrintingWindowsForm01182008021239AM/PrintingWindowsForm.aspx [ ^ ]
Try
Print Windows Forms w/o using API[^]
http://www.c-sharpcorner.com/UploadFile/srajlaxmi/PrintingWindowsForm01182008021239AM/PrintingWindowsForm.aspx[^]


不要打印表格,不要打印控件.相反,您应该具有一些数据层并打印数据中的所有内容.使用类System.Drawing.Printing.PrintDocument.这里有一个很好的代码示例: http://msdn.microsoft.com/zh-cn/library/system.drawing.printing.printdocument.aspx [ http://en.wikipedia .org/wiki/Architectural_pattern_(computer_science) [^ ]):

MVVM —模型视图视图模型,
http://en.wikipedia.org/wiki/Model_View_ViewModel [> http://en.wikipedia.org/wiki/Model-view-controller [ ^ ])),

MVA —模型视图适配器,
http://en.wikipedia.org/wiki/Model–view–adapter [ ^ ],

MVP —模型视图呈现器,
> http://en.wikipedia.org/wiki/Model-view-presenter [ ^ ].
请注意这些架构的动机.如果您了解它,就可以提出更好的设计思路.

—SA
Don''t print Form, don''t print controls. Instead, you should have some data layer and print everything from data. Use the class System.Drawing.Printing.PrintDocument. There is a good code sample here: http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^].

Even if you don''t use data binding, you need to code something similar. You data is used to populate UI, UI should be able to change the data layer, and the whole data layer is used to update the state of UI.

I suggest you learn and analyze applicability of the following architectural patterns (http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[^]):

MVVM — Model View View Model,
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],

MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),

MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],

MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
Pay attention for the motivation of those architectures. If you understand it, you would be able to create better design ideas.

—SA


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

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