gpt4 book ai didi

vb.net - 正确使用 PrintPreview 对话框

转载 作者:行者123 更新时间:2023-12-04 02:17:14 27 4
gpt4 key购买 nike

这是我第一次必须使用打印预览,我很困惑,所以我需要一个建议:

enter image description here

这是我要打印的对话框:

这是它目前在我的打印预览对话框中的样子(搞砸了): enter image description here

这是我现在的完整代码:

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

请问我该如何正确设置?

最佳答案

将页面方向设置为横向

printDocument1.DefaultPageSettings.Landscape = true

有关详细信息,请参阅 PrintDocument.DefaultPaperSettings 上的 MSDN 文档.

关于vb.net - 正确使用 PrintPreview 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13782735/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com