[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Landscape mode not happening

Posted on 2005-04-05
7
Medium Priority
?
491 Views
Last Modified: 2008-02-01
Can anyone help me get a report to print in Landscape Mode?  (Using Windows Form, not ASP.)

I need to determine what category of data has been passed to the print routine, and dynamically switch the page orientation.

Setting "e.PageSettings.Landscape = true" has no effect.

What am I missing?

Capt
0
Comment
Question by:Glen Gibb
  • 4
  • 3
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 13713115
what are you using to print?
0
 

Author Comment

by:Glen Gibb
ID: 13713420
Here's the routine.


Private Overloads Sub OnPrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles MyBase.PrintPage

mPageNumber += 1

Dim cat As TestCategory = TestCategory.GetById(CurrentReport.CategoryFK)
Select Case cat.CatKey
Case "M", "S"
      e.PageSettings.Landscape = True
Case Else
      e.PageSettings.Landscape = False
End Select

' create ReportPageEventArgs object ...
Dim page As New ReportPageEventArgs(e, mPageNumber, mFont, mBrush, mFooterLines)

' if we're generating page 1 raise the ReportBegin event
If mPageNumber = 1 Then
  RaiseEvent ReportBegin(Me, page)
End If

' generate the page header/body/footer
 Select Case ReportType
   Case "Lab Slips"
      RaiseEvent PrintLabSlipDocument(Me, page)
   Case "Report"
      RaiseEvent PrintReportDocument(Me, page)
End Select

' if there are no more pages to generate then raise the ReportEnd event
If Not page.HasMorePages Then
      RaiseEvent ReportEnd(Me, page)
End If

' restore page values to the underlying PrintPageEventArgs object
e.Cancel = page.Cancel
e.HasMorePages = page.HasMorePages

End Sub
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 13713459
try something like this:

Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' Specify the printer to use
pd.PrinterSettings.PrinterName = ListBox1.SelectedItem
' Set the page orientation to landscape.
pd.DefaultPageSettings.Landscape = True
pd.Print()

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:Glen Gibb
ID: 13713785
This approach does work.  If I set the "defaultpagesettings" property before calling the above routine, the orientation does move to landscape.

On the other hand, my routine is inside a printdocument class.  Is there no way it can respond to the type of data and change the orientation of the page 'on the fly'?

Capt
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1500 total points
ID: 13715216
once the job is started, I don't think you can change the orientation.
0
 

Author Comment

by:Glen Gibb
ID: 13720939
MSDN's remarks on PageSettings class seems to suggest that it's at least possible.  (If I read this correctly.)

"This class is used to specify settings that modify the way a page will be printed. Typically, you set default settings for all pages to be printed through the PrintDocument.DefaultPageSettings property. To specify settings on a page-by-page basis, handle the PrintDocument.PrintPage or PrintDocument.QueryPageSettings event and modify the PageSettings argument included in the PrintPageEventArgs or QueryPageSettingsEventArgs, respectively."

However, setting the PrintPageEventArgs  "Landscape = true" doesn't seem to be cutting the mustard.

It would sure simplify things if I could "specify settings on a page-by-page basis," however.

Capt
0
 

Author Comment

by:Glen Gibb
ID: 13721541
The answer lies in the "QueryPageSettings" event of the print document.

You can change PageSettings at this point.  After that, it seems that you're committed.

Although the question wasn't answered directly, it made me hunt thru MSDN more carefully.  Tnx.

Capt
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month18 days, 13 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question