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
I just tested this out and it worked fine for me just setting:
this.ultraGridPrintDocument1.DefaultPageSettings.Landscape = true;
I put the UltraGridPrintDocument and the UltraPrintPreviewDialog on the form at design-time and set the Grid property and the Document property respectively at design-time. Then in the Form_Load, I set the DefaultPageSettings to Landscape.
When I show the dialog, everything shows up in Landscape and the Page Setup dialog has Landscape selected.
Perhaps something in your code is changing re-setting the property somewhere? Or maybe it has to do with the order in which you are applying the settings. Or perhaps you are using an old version of the controls? Maybe you need the latest hotfix?
If you are unable to get this to work, I recommend that you Submit an incident to Infragistics Developer Support and include a small sample project demonstrating the behavior so they can check it out.
I couldn't understand how you got yours working, and mine wouldn't. After compairing code I found the issue.
I used Me.UltraGridPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = True, the key being "PrinterSettings" where you used Me.UltraGridPrintDocument.DefaultPageSettings.Landscape = True. When I removed PrinterSettings it worked a treat.
Thank you very much.
I did the same thing today, Maybe I've found the cause. It doesn't work fine if you use "Me.UltraGridPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = True", and if you use "Me.UltraGridPrintDocument.DefaultPageSettings.Landscape = True" , it will be OK.