怎样用热敏打印机把vb.net窗体内文本框内容打印出来

2024-11-26 10:25:12
推荐回答(2个)
回答1:

用PrintForm控件,在Visual Basic PowerPacks项目列表中vb2008 SP1以后版本就有了,下面是代码
Imports System.Drawing.Printing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'先设置打印页面的页边距
With Me.PrintForm1
Dim myMargins As New Margins '页边距设置信息是存放在这个Margins类型的对象中的
With myMargins '分别设置上下左右边距,
.Left = 12
.Right = 12
.Top = 12
.Bottom = 12
End With
.PrinterSettings.DefaultPageSettings.Margins = myMargins '把myMargins对象赋给PrintForm1的设置属性
End With

Me.Button1.Visible = False '这个是在打印的时候隐藏打印按钮
Me.PrintForm1.Form = Me '设置要打印的窗体
Me.PrintForm1.Print() '调用打印窗体方法
Me.Button1.Visible = True '再把隐藏的打印按钮显示出来
End Sub

回答2:

用屏幕硬拷贝Alt+PrintScreen(PrtScrn)