Printing a Winform in landscape mode

divjoy

Well-known member
Joined
Aug 25, 2013
Messages
160
Programming Experience
1-3
Hi,

I am trying to print a form that has a datagridview with 6 columns and about 30 rows in landscape. Sounds simple! But its not.

My code uses a bitmap variable and Graphics and Print component to do this but I end up printing part of the main screen from top left to about half way over missing out part of the form I wish to print.
I start with using a panel and use the "Graphics.ClientScreen" to get the dimensions which I think is where I may be going wrong!

I would be grateful for any help, I didn't post my code as I don't think it would be any help to anyone.

Thanks

Gerry
 
You really shouldn't be printing a picture of the form in the first place. The form has all sorts of visual elements that you don't need to print. Your grid displays data in a tabular format so just print a table. Draw the grid lines yourself and draw the text in the cells yourself. That would mean handling the PrintPage event of a PrintDocument object and calling e.Graphics.DrawLine and .DrawString as required.
 
Back
Top