关于listbox打印的问题
我在listboxj里添加了3项如:111122223333我想打他们按listbox显示顺序从上到下打印到一页里,我使用如下代码PrivateSub打印ToolStri...
我在listboxj里添加了3项如:
1111
2222
3333
我想打他们按listbox显示顺序从上到下打印到一页里,我使用如下代码
Private Sub 打印ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 打印ToolStripMenuItem.Click
Dim printDialog2 As PrintDialog = New PrintDialog
printDialog2.Document = PrintDocument2
Dim result As DialogResult = printDialog2.ShowDialog
If (result = Windows.Forms.DialogResult.OK) Then
PrintDocument2.Print()
End If
End Sub
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
e.Graphics.DrawString(ListBox1.Items(i), New Font("宋体", 20, FontStyle.Regular), Brushes.Black, 120, 10)
e.HasMorePages = False
Next
End Sub
但打印出来的三行都重复打印在第一行,请问问题出在哪里,谢谢! 展开
1111
2222
3333
我想打他们按listbox显示顺序从上到下打印到一页里,我使用如下代码
Private Sub 打印ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 打印ToolStripMenuItem.Click
Dim printDialog2 As PrintDialog = New PrintDialog
printDialog2.Document = PrintDocument2
Dim result As DialogResult = printDialog2.ShowDialog
If (result = Windows.Forms.DialogResult.OK) Then
PrintDocument2.Print()
End If
End Sub
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
e.Graphics.DrawString(ListBox1.Items(i), New Font("宋体", 20, FontStyle.Regular), Brushes.Black, 120, 10)
e.HasMorePages = False
Next
End Sub
但打印出来的三行都重复打印在第一行,请问问题出在哪里,谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询