我们如何在横向模式下在vb.net中打印?

时间:2016-11-20 08:27:56

标签: vb.net printing landscape

其实我正在制作一个学校管理项目,我想打印学生的成绩。现在的问题是,控件所在的winform预览是以纵向模式进行而不是横向模式。

这是我用来打印的代码:

 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

我附上了上面代码的图片。 https://community.dynamics.com/crm/f/117/p/115109/321670#321670

我希望它应该预览并以横向模式而不是肖像进行打印。

我需要更改位图属性中的任何内容吗?任何帮助将不胜感激

感谢。

0 个答案:

没有答案