From time to time on still has to use the built in Print abilities of winforms. But you should be using microsoft reporting a lot more.
And one of the things you micht want to do is to print something in lanscape mode.
So you do this.
vbnet
Dim _printDocument = New Drawing.Printing.PrintDocument
Dim _printPreviewDialog = New PrintPreviewDialog
_printPreviewDialog.Document = _printDocument
_printDocument.PrinterSettings.DefaultPageSettings.Landscape = True
_printPreviewDialog.ShowDialog(Me)
But alas that doesn’t actually turn the page. And God only knows what it really does because I have no idea.
But luckily we can do this instead.
vbnet
Dim _printDocument = New Drawing.Printing.PrintDocument
Dim _printPreviewDialog = New PrintPreviewDialog
_printPreviewDialog.Document = _printDocument
_printDocument.DefaultPageSettings.Landscape = True
_printPreviewDialog.ShowDialog(Me)
And yes that gives the desired result.
Did you spot the difference?
Well, you don’t use the PrinterSettings.DefaultPageSettings on PrintDocument but you use the DefaultPageSettings on PrintDocument to get it to work. Someone might need to rethink the ApI there, but I guess that has no chance what so ever of happening since winforms is supposedly dead.