Click here to Skip to main content
15,885,186 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.
Posted
Comments
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: 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
 
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