Home » VB.Net

Print form in landscape

I am using VB express 2008. I want to be able to print a form in landscape using the powerpack print form control. How do I do this???


4 Answers Found


Answer 1


I have the code:

Imports System.Drawing.Printing

Dim ps As New PageSettings

ps.Landscape = True

Does anyone know where I go from here???


Answer 3

Thanks, but this doesn't work. It is saying:

Name Printer is not declared


Name vbPRORLandscape is not declared

Any other suggestions???


Answer 4

Here's a print  method I wrote to print monthly time sheets (in Landscape mode) where I work.  I wrote it with VB Express 2008 as a WPF application.


 Private Sub PrintTheTimeSheet()
  Dim d As New PrintDialog

  Dim pageMargin As Integer = 0
  Dim pageSize As New Size(d.PrintableAreaWidth - pageMargin * 2, d.PrintableAreaHeight - 30)

  winTimeSheet.Arrange(New Rect(pageMargin, pageMargin, pageSize.Height, pageSize.Width))

  d.PrintQueue = LocalPrintServer.GetDefaultPrintQueue
  d.PrintTicket.PageOrientation = PageOrientation.Landscape
  d.PrintVisual(winTimeSheet, "Time Sheet")
 End Sub


It prints to the Default printer (in this case the form  named winTimeSheet is printed).  You may want to play with the settings, margins etc., these work with my printer, but you should be able to adapt it to your needs.

You also might want to open the print dialog and print from there.  If you go to online help in vb and type in the keywords you can find out how to use the various members of the different classes and find out which references you need to add and import to make everything work.

Hope this helps.





<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure