16,554
社区成员
发帖
与我相关
我的任务
分享
'调用打印
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 str = "该程序演示打印功能"
Dim g As Graphics = e.Graphics '这是可以用来画图打印文字的对象
Dim f As Font = New Font("宋体", 16)
Dim CurX, CurY As Integer
CurX = 40
CurY = 40
g.DrawString(str, f, Brushes.Black, CurX, CurY)
End Sub
'预览
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
End Sub