列表视图打印PrintPage(s)

时间:2015-01-07 01:19:23

标签: .net vb.net listview graphics printing

我正在制作一个测验程序,但我真的需要一些关于在vb.net中从listview打印项目的帮助。我可以在打印预览中成功显示项目,但问题是如果当前页面接近纸张末尾(A4),如何进入下一页?还有如何使其自动调整,以便如果问题/答案太长,它会将文本换行到下一行。我是新手,这就是为什么我不知道接下来该做什么。请帮忙。到目前为止,这是我的代码。非常感谢..

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

        Dim font1 As New Font("Verdana", 11, FontStyle.Regular)
        Dim ctr As Integer = 0
        Dim nextline As Integer = 0

        Do
            e.Graphics.DrawString(ctr + 1 & ": " & ListView1.Items(ctr).SubItems(3).Text, 
                    font1, Brushes.Black, 100, 30 + nextline)
            e.Graphics.DrawString("A: " & ListView1.Items(ctr).SubItems(4).Text, 
                    font1, Brushes.Black, 100, 60 + nextline)
            e.Graphics.DrawString("B: " & ListView1.Items(ctr).SubItems(5).Text, 
                    font1, Brushes.Black, 100, 90 + nextline)
            e.Graphics.DrawString("C: " & ListView1.Items(ctr).SubItems(6).Text, 
                    font1, Brushes.Black, 100, 120 + nextline)
            e.Graphics.DrawString("D: " & ListView1.Items(ctr).SubItems(7).Text, 
                    font1, Brushes.Black, 100, 150 + nextline)

            nextline = nextline + 200

            ctr = ctr + 1
        Loop Until ctr = ListView1.Items.Count

End Sub

0 个答案:

没有答案