【发布时间】:2019-10-20 11:31:20
【问题描述】:
我正在打印组框,但打印不正确。 如何打印并适合 A4 尺寸的纸张。 这是我的代码
Private Sub printbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles printbtn.Click
PrintDialog1.Document = PrintDocument1 'PrintDialog associate with PrintDocument.
If PrintDialog1.ShowDialog() = DialogResult.OK Then
PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim x As Single = e.MarginBounds.Left
Dim y As Single = e.MarginBounds.Top
Dim bmp As New Bitmap(Me.GroupBox1.Width, Me.GroupBox1.Height)
Me.GroupBox1.DrawToBitmap(bmp, New Rectangle(0, 0, Me.GroupBox1.Width, Me.GroupBox1.Height))
e.Graphics.DrawImage(DirectCast(bmp, Image), x, y)
End Sub
并得到这样的输出click
【问题讨论】:
标签: vb.net