vb.net 打印机如何:点击Button1后将textbox1中“1234” 打印到纸上
VB.net新手,摸索中。需要详细可执行的命令。打印的字体和纸张的位置如何设置?打印机需要在VB.NET中设置吗?越简单越好啊...
VB.net新手,摸索中。需要详细可执行的命令。打印的字体和纸张的位置如何设置?打印机需要在VB.NET中设置吗?
越简单越好啊 展开
越简单越好啊 展开
1个回答
展开全部
Imports System.Drawing.Printing
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim PrintDoc As New PrintDocument
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
PrintDoc.Print()
Catch ex As Exception
MessageBox.Show("sorry", ex.ToString)
End Try
End Sub
Private Sub PrintText(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim PrintDoc As New PrintDocument
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
PrintDoc.Print()
Catch ex As Exception
MessageBox.Show("sorry", ex.ToString)
End Try
End Sub
Private Sub PrintText(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询