关于VB.NET编制打印程序,打印出来页面内容总是重叠在一起的问题 50
用VB.NET编制一个多页打印程序,为什么页面总是会重叠在一起。比如,我打印三页内容,然实际只打印了两页,第一页上是需要打印的第一页和第二页的内容,第二页上是需要打印的第...
用VB.NET编制一个多页打印程序,为什么页面总是会重叠在一起。比如,我打印三页内容,然实际只打印了两页,第一页上是需要打印的第一页和第二页的内容,第二页上是需要打印的第三的内容。差了很多资料现在仍然无法解决~~~
哥们~~你的这个VB6的 我现在问的是2005的VB.net里面的~~~ 展开
哥们~~你的这个VB6的 我现在问的是2005的VB.net里面的~~~ 展开
2个回答
展开全部
参考:
把执行SQL语句后得到的记录集逐条(含字段名)显示在LISTVIEW控件中
'----------------------------------------------------------------
Public Sub ListUpdate(ByRef rs As Recordset, ByRef lv As ListView)
Dim head As ColumnHeader, Item As ListItem
Dim i As Integer, j As Integer
Dim lvWidth As Integer
lvWidth = lv.Width
'初始化LISTVIEW的某些属性
lv.View = lvwReport
lv.GridLines = True
lv.FullRowSelect = True
lv.ListItems.Clear
lv.ColumnHeaders.Clear
For i = 0 To rs.Fields.Count - 1
Set head = lv.ColumnHeaders.Add
head.Text = rs.Fields(i).Name
head.Width = lvWidth / rs.Fields.Count
Next
For j = 1 To PERPAGE
If rs.EOF Then Exit For
Set Item = lv.ListItems.Add
Item.Text = "" & rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Item.SubItems(i) = "" & rs.Fields(i).Value
Next
rs.MoveNext
Next
End Sub
' 打印
Public Sub PrintRecordset(ByRef recRecordset As Recordset, ByVal strType As String)
Dim LeftMargin As Integer
Dim HeadTopPosition As Integer
Dim FieldNum As Integer
Dim PageCounter As Integer
Dim MyRecordset As ADODB.Recordset
Const FooterTopPosition = 24
Set MyRecordset = recRecordset
PageCounter = 1
' 设 置Printer 对 象 坐 标 的 度 量 单 位 为 厘 米
Printer.ScaleMode = vbCentimeters
LeftMargin = 1.5
HeadTopPosition = 2
' 定 义 打 印 页 左 上 角 的X 坐 标 和Y 坐 标, 通 过 改 变ScaleLeft 和ScaleTop 的 值, 可 改 变 打 印 页 的 左 边 距 和 上 边 距
Printer.ScaleLeft = -LeftMargin
Printer.ScaleTop = -HeadTopPosition
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 12
Printer.Print "音像店顾客管理系统"
Printer.Print strType
Printer.Print ""
If MyRecordset.EOF And MyRecordset.BOF Then
MsgBox "No Record At Presend!", vbCritical And vbOKOnly, "Print Error"
Exit Sub
End If
MyRecordset.MoveFirst
Do Until Printer.CurrentY > FooterTopPosition
'Print the fields of the recordset in sequence
For FieldNum = 0 To MyRecordset.Fields.Count - 1
Printer.Print MyRecordset.Fields(FieldNum).Name & _
": " & _
MyRecordset.Fields(FieldNum).Value
If Printer.CurrentY > FooterTopPosition Then
Printer.CurrentX = 8
Printer.Print "Page: " & PageCounter
' 创 建 多 页 文 档
Printer.NewPage
PageCounter = PageCounter + 1
End If
Next FieldNum
MyRecordset.MoveNext
If MyRecordset.EOF Then Exit Do
' 在 记 录 之 间 空 一 行
Printer.Print ""
Loop
'Print the Page number as a footer
Printer.CurrentX = 8
Printer.CurrentY = FooterTopPosition
Printer.Print "Page: " & PageCounter
' 将 输 出 送 到 打 印 机
Printer.EndDoc
End Sub
把执行SQL语句后得到的记录集逐条(含字段名)显示在LISTVIEW控件中
'----------------------------------------------------------------
Public Sub ListUpdate(ByRef rs As Recordset, ByRef lv As ListView)
Dim head As ColumnHeader, Item As ListItem
Dim i As Integer, j As Integer
Dim lvWidth As Integer
lvWidth = lv.Width
'初始化LISTVIEW的某些属性
lv.View = lvwReport
lv.GridLines = True
lv.FullRowSelect = True
lv.ListItems.Clear
lv.ColumnHeaders.Clear
For i = 0 To rs.Fields.Count - 1
Set head = lv.ColumnHeaders.Add
head.Text = rs.Fields(i).Name
head.Width = lvWidth / rs.Fields.Count
Next
For j = 1 To PERPAGE
If rs.EOF Then Exit For
Set Item = lv.ListItems.Add
Item.Text = "" & rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Item.SubItems(i) = "" & rs.Fields(i).Value
Next
rs.MoveNext
Next
End Sub
' 打印
Public Sub PrintRecordset(ByRef recRecordset As Recordset, ByVal strType As String)
Dim LeftMargin As Integer
Dim HeadTopPosition As Integer
Dim FieldNum As Integer
Dim PageCounter As Integer
Dim MyRecordset As ADODB.Recordset
Const FooterTopPosition = 24
Set MyRecordset = recRecordset
PageCounter = 1
' 设 置Printer 对 象 坐 标 的 度 量 单 位 为 厘 米
Printer.ScaleMode = vbCentimeters
LeftMargin = 1.5
HeadTopPosition = 2
' 定 义 打 印 页 左 上 角 的X 坐 标 和Y 坐 标, 通 过 改 变ScaleLeft 和ScaleTop 的 值, 可 改 变 打 印 页 的 左 边 距 和 上 边 距
Printer.ScaleLeft = -LeftMargin
Printer.ScaleTop = -HeadTopPosition
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 12
Printer.Print "音像店顾客管理系统"
Printer.Print strType
Printer.Print ""
If MyRecordset.EOF And MyRecordset.BOF Then
MsgBox "No Record At Presend!", vbCritical And vbOKOnly, "Print Error"
Exit Sub
End If
MyRecordset.MoveFirst
Do Until Printer.CurrentY > FooterTopPosition
'Print the fields of the recordset in sequence
For FieldNum = 0 To MyRecordset.Fields.Count - 1
Printer.Print MyRecordset.Fields(FieldNum).Name & _
": " & _
MyRecordset.Fields(FieldNum).Value
If Printer.CurrentY > FooterTopPosition Then
Printer.CurrentX = 8
Printer.Print "Page: " & PageCounter
' 创 建 多 页 文 档
Printer.NewPage
PageCounter = PageCounter + 1
End If
Next FieldNum
MyRecordset.MoveNext
If MyRecordset.EOF Then Exit Do
' 在 记 录 之 间 空 一 行
Printer.Print ""
Loop
'Print the Page number as a footer
Printer.CurrentX = 8
Printer.CurrentY = FooterTopPosition
Printer.Print "Page: " & PageCounter
' 将 输 出 送 到 打 印 机
Printer.EndDoc
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询