Hi,
I've got a grid that I would like to print or print preview. The default setting for the orientation is landscape. I've searched this forum for the answer with mixed results.
I assumed rightly or wrongly that using the following setting would change the orientation to landscape. When I print preview the document is still in portrait.
Me.UltraGridPrintDocument1.PrinterSettings.DefaultPageSettings.Landscape = True
I then found a post describing capturing the UltraGridPrintDocument1_QueryPageSettings event and using e.PageSettings.Landscape to set it to landscape.
I managed to get that to work however when you go to page setup from the print preview dialog, although the image is in landscape, the page setup says Portrait.
Could you let me know what I'm doing wrong?
Thanks
Nathan
Hi Nathan,
It depends how you are printing. Can you post there code you are using to show the PrintPreview?
Hi Mike,
My form contains a UltraWinGrid called UltraGridData. I have an UltraPrintPreviewDialog called UltraPrintPreviewDialog, and an UltraGridPrintDocument called UltraGridPrintDocument.
The UltraGridPrintDocument has the grid set to UltraGridData. The UltraPrintPreviewDialog has its document set to UltraGridPrintDocument. This is in a MDI form. This form has two public methods for the MDI parent to call when the Print or Print Preview has been selected from the menu. They are as follows:
Public Sub Print() Me.UltraGridPrintDocument.Print() End Sub
Public Sub PrintPreview() Me.UltraPrintPreviewDialog.ShowDialog(Me) End Sub
In the form load I set the landscape property to true
Private Sub GenericDataView_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.UltraGridPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = True End Sub
As that didn't seem to work, I added the following temp workaround which gave me the landscape view but the dialog problem reported above.
Private _initialised As Boolean = False 'we need to set it on the first time this query event is used to force the default setting
Private Sub UltraGridPrintDocument_QueryPageSettings(ByVal sender As Object, ByVal e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles UltraGridPrintDocument.QueryPageSettings
If Not _initialised Then e.PageSettings.Landscape = Me.UltraGridPrintDocument.PrinterSettings.DefaultPageSettings.Landscape _initialised = True End If
End Sub