在 VB.NET 中编程还有另一个小问题。我有一个TextBox
使用 .txt 从 txt 文件填充的StreamReader
. 基本上我有一个打印选项,但只能打印中显示的内容TextBox
,如果在TextBox
更下方有更多信息需要滚动,则不会打印(希望这是有道理的!)。有什么办法可以解决这个问题,以便打印所有信息?
这是我的代码:
Imports System.Drawing.Printing
Public Class JobList
Private Sub JobList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objReader As New System.IO.StreamReader("C:\test\JobLog.txt", True)
txtJL.Text = objReader.ReadToEnd
objReader.Close()
End Sub
Private Sub printText(ByVal sender As System.Object, ByVal ev As PrintPageEventArgs)
Dim font As New Font("Arial", 16, FontStyle.Regular)
ev.Graphics.DrawString(txtJL.Text, font, Brushes.Black, 100, 100)
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Dim printDoc As New PrintDocument
AddHandler printDoc.PrintPage, AddressOf Me.printText
printDoc.Print()
End Sub
End Class