How do we print in vb.net in landscape mode?
<p>Actually i am working on a school management project in which i want to print result of student. Now the problem is that the preview of winform in which the controls are there is coming in portrait mode and not in landscape mode.</p>

<p>This is my code i used to print:</p>

<pre><code> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    'Add a Panel control.
    Dim panel As New Panel()
    Me.Controls.Add(panel)

    'Create a Bitmap of size same as that of the Form.
    Dim grp As Graphics = panel.CreateGraphics()
    Dim formSize As Size = Me.ClientSize
    Bitmap = New Bitmap(formSize.Width, formSize.Height, grp)
    grp = Graphics.FromImage(Bitmap)

    'Copy screen area that that the Panel covers.
    Dim panelLocation As Point = PointToScreen(panel.Location)
    grp.CopyFromScreen(panelLocation.X, panelLocation.Y, 0, 0, formSize)


    'PrintPreviewDialog1.ShowDialog()

    PrintPreviewDialog1.Document = PrintDocument1
    PrintPreviewDialog1.PrintPreviewControl.Zoom = 1
    PrintPreviewDialog1.ShowDialog()

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    e.Graphics.DrawImage(bitmap, 0, 0)
End Sub
</code></pre>

<p>i am attaching a picture of what above code does.
<a href="https://i.stack.imgur.com/fpKuG.png" rel="nofollow noreferrer">Portrait Result</a></p>

<p>I want that it should be previewed and get print in landscape mode instead of portrait.</p>

<p>do i need to change anything in bitmap property? any help would be appreciated</p>

<p>Thanks.</p>