Click here to Skip to main content
15,612,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

We are using a windows form screen for visualization. We have a requirement to print this visualization screen.

The problem is we have huge controls on the form (we did not take these controls from the toolbox, instead we are drawing those using some classes like Rectangle) and used both horizontal and vertical scroll bars. But it is printing only the visible part of the screen, but not the other. I used g.drawImge() to draw this visualization screen.

I have seen many examples but it is not matching with my requirements.

What I have tried:

I have implemented it like below
link here
Updated 13-Apr-21 0:58am
Samatha Reddy G 12-Apr-21 11:51am    
Thank you for your reply. My problem is to print the full-screen of the windows forms, including the invisible part of the screen (when we scroll vertically and horizontally
I have some other controls to print, these controls are not visible until and unless we scroll, I also need to print those controls).
Richard MacCutchan 13-Apr-21 3:49am    
The answer is that you need to calculate the 'logical' position and dimensions of your form and all its controls. You must then scale those values (up or down) to fit the destination where they are to be displayed. For your screen that will mean scaling down, and for a large printout it will probably mean scaling up.

1 solution

Basically, don't.
Stop printing the form and it's controls, and print the data those controls contain.
Use the PrintDocument Class (System.Drawing.Printing) | Microsoft Docs[^] and you get paging as well as the ability to print what you want, where you want, how your want - which means your printout can look like a document instead of a screenshot!

It's a little more work to set up, but it's a lot more flexible and looks a damn sight more professional. And not that difficult to work with once you get the hang of it.
Share this answer
Samatha Reddy G 12-Apr-21 7:37am    
thank you for your answer. I don't need any data which is there on the form, I need to print the screen as it is, it's like the same screenshot. That's my requirement.
OriginalGriff 12-Apr-21 8:37am    
Then why are you talking about printing things you can't see on the screen?
Samatha Reddy G 12-Apr-21 11:39am    
It's our requirement. Our client needs to print that on A0 and A1 paper. If I'm able to save the complete form, then I can print that.
please help me with this and let me know if you need any other info.

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