主题:vb.net的打印问题
用以下的程序打印不能换页,需打印的内容会打印在一张纸上,请高手指点指点!
Sub pd_print(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim fnt, fnt1 As Font
fnt = New Font("黑体", 13)
fnt1 = New Font("黑体", 15)
e.PageSettings.Margins.Top = 0
e.PageSettings.Margins.Left = 0
Dim i, a As Long
a = 14 ' 需打印的证数
Dim f As String
Dim k As Short = 0 '打印行
Dim ycd As Short '打印的位置
For i = 1 To a
ycd = 70 + k * 275
k = k + 1
f = CStr(ycd) + "_" + CStr(i)
e.Graphics.DrawString(f, fnt, Brushes.Black, 22, ycd)
If ycd > 900 Then
k = 0
e.HasMorePages = True
End If
Next
e.HasMorePages = False
fnt.Dispose()
End Sub
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf Me.pd_print
pd.Print()
End Sub
End Class
Sub pd_print(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim fnt, fnt1 As Font
fnt = New Font("黑体", 13)
fnt1 = New Font("黑体", 15)
e.PageSettings.Margins.Top = 0
e.PageSettings.Margins.Left = 0
Dim i, a As Long
a = 14 ' 需打印的证数
Dim f As String
Dim k As Short = 0 '打印行
Dim ycd As Short '打印的位置
For i = 1 To a
ycd = 70 + k * 275
k = k + 1
f = CStr(ycd) + "_" + CStr(i)
e.Graphics.DrawString(f, fnt, Brushes.Black, 22, ycd)
If ycd > 900 Then
k = 0
e.HasMorePages = True
End If
Next
e.HasMorePages = False
fnt.Dispose()
End Sub
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf Me.pd_print
pd.Print()
End Sub
End Class