This is my first time I have to use print preview and I got confused so I need a suggestion:
this is the dialog that I wanna print:
this is how it currently looks in my PrintPreview dialog (messed up):
this is my full code at the moment:
Public Class frmPRINT
Private Sub btnPrint_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim bm As New Bitmap(DataGridView1.Width, DataGridView1.Height)
DataGridView1.DrawToBitmap(bm, New Rectangle(0, 0, DataGridView1.Width, DataGridView1.Height))
e.Graphics.DrawImage(bm, 0, 0)
End Sub
Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click
PrintPreviewDialog1.WindowState = FormWindowState.Normal
PrintPreviewDialog1.StartPosition = FormStartPosition.CenterScreen
PrintPreviewDialog1.ClientSize = New Size(600, 600)
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
End Sub
End Class
how can I set this up properly please?
Set the page orientation to landscape with
printDocument1.DefaultPageSettings.Landscape = true
For more information, see the MSDN documentation on PrintDocument.DefaultPaperSettings
.