VB.NET中使用PrintDocument控件实现打印

feitian1 2006-05-26 02:05:36
我已经使用画图设计好了纸张格式.纸张设计格式相当于5*2列的表格形式.假如规定一张A4纸上可以打印10条数据.数据库中假如有32条数据,现在已经打印了10条数据,那其他剩下数据在下页中显示,那么分页怎么实现呢?那纸张格式也要显示出来.
高手请指.谢谢!!
...全文
1119 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sx_lxh 2006-05-27
  • 打赏
  • 举报
回复
If iCurPageNum < strPrint.GetUpperBound(0) Then
    e.HasMorePages = true 
else
    e.HasMorePages =false
End If
kssys 2006-05-27
  • 打赏
  • 举报
回复
参看:http://community.csdn.net/Expert/TopicView3.asp?id=4730615

回复人:kssys(泡在CSDN,骗分) ( 四级(中级)) 信誉:100 2006-5-6 22:38:38 得分:0
?

很晚了,随意写一下。
Imports System.IO
Imports System.Drawing.Printing

Private printFont As New Font("Arial", 10)
Private iCurPageNum As Integer = 0
Private strPrint() As String = {"第一页测试字串", "哈哈这是第二页"}

Private Sub PrintDoc_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDoc.PrintPage

  Dim rectDraw As New RectangleF( _
e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)

  e.Graphics.DrawString(strPrint(iCurPageNum), printFont, Brushes.Black, rectDraw, strFormat)

  If iCurPageNum < strPrint.GetUpperBound(0) Then
    e.HasMorePages = False
  else
    e.HasMorePages =True
  End If
  iCurPageNum += 1
End Sub

hzybc 2006-05-27
  • 打赏
  • 举报
回复
e.HasMorePages = True '不是立即换页的命令,
Exit Sub '加这句才是


打印时要控制已打印的位置和数量
copico 2006-05-26
  • 打赏
  • 举报
回复
http://net.kaifz.com/PrintDocument-t165696.htm

16,722

社区成员

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

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