Click here to Skip to main content
15,610,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
R. Giskard Reventlov 18-Jul-11 10:01am    
What have you tried for yourself?
johannesnestler 18-Jul-11 10:32am    
an easy solution could be just taking a screenshot of your app (image) and print that? I can share code for taking application specific screenshot (like alt+Print) if you want to try this "solution".

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:[^].

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 ([^]):

MVVM — Model View View Model,[^],

MVC — Model-View-Controller,[^]),

MVA — Model-View-Adapter,–view–adapter[^],

MVP — Model-View-Presenter,[^].
Pay attention for the motivation of those architectures. If you understand it, you would be able to create better design ideas.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900