VB.NET打印

xayzmb 2012-08-29 01:37:32
以前在VB6中
可以用printer对象直接打印
比如:

Printer.Print "打印出这一行字"
Printer.EndDoc

会调用当前默认打印机打印

在VB.NET中
好象是用PrintDocument
但具体操作网上写的太复杂
哪位能用PrintDocument写一下上面那两行代码完成的功能?
...全文
319 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
smisjk62 2012-11-21
  • 打赏
  • 举报
回复
新手,打印还是不会做!找了好久了
xxxuan 2012-09-14
  • 打赏
  • 举报
回复
用水晶报表
程序迷 2012-09-09
  • 打赏
  • 举报
回复
到http://myyouping.download.csdn.net/下载一个通用的.NET下用的打印控件
xayzmb 2012-08-29
  • 打赏
  • 举报
回复
更正:
'上面代码有几行多余了

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
PrintDocument1.Print()

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawString("这是第一行字", New Font("宋体", 20), New Pen(Color.Black, 1).Brush, 30, 30)
e.Graphics.DrawString("这是第二行字", New Font("黑体", 30), New Pen(Color.Red, 2).Brush, 50, 50)

End Sub
xayzmb 2012-08-29
  • 打赏
  • 举报
回复 1
自已解决了
代码:
'添加一个PrintDocument控件,一个button控件
'添加下列代码

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.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 a As String
a = "abcd"
Dim mypen As Pen = New Pen(Color.Blue, 2)
e.Graphics.DrawString("这是第一行字", New Font("宋体", 20), New Pen(Color.Black, 1).Brush, 30, 30)
e.Graphics.DrawString("这是第二行字", New Font("黑体", 30), New Pen(Color.Red, 2).Brush, 50, 50)

End Sub

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧