使用制表符格式打印 WinForms 文本框
我一直在研究一些打印列出联系信息的文本框的代码。当我尝试打印它时,它不会打印出我用来格式化文本的选项卡。这是我的代码:
Private Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs) _
Handles prndoc.PrintPage
Dim fnt As Font = resultTextBox.Font
ev.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Dim area As SizeF = New SizeF(ev.MarginBounds.Width, ev.MarginBounds.Height)
Dim lines, chars As Integer
ev.Graphics.MeasureString(resultTextBox.Text.Substring(mStringPos), fnt, _
area, StringFormat.GenericTypographic, chars, _
lines)
Dim rc As New RectangleF(ev.MarginBounds.Left, ev.MarginBounds.Top, _
ev.MarginBounds.Width, ev.MarginBounds.Height)
ev.Graphics.DrawString(resultTextBox.Text.Substring(mStringPos, chars), _
fnt, Brushes.Black, rc, _
StringFormat.GenericTypographic)
mStringPos += chars
ev.HasMorePages = mStringPos < resultTextBox.Text.Length
End Sub
有人可以告诉我我做错了什么吗?
I have been working on some code that prints a textbox that lists contact information. When I try to print it, it doesn't print out the tabs that I used to format the text. Here is my code:
Private Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs) _
Handles prndoc.PrintPage
Dim fnt As Font = resultTextBox.Font
ev.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Dim area As SizeF = New SizeF(ev.MarginBounds.Width, ev.MarginBounds.Height)
Dim lines, chars As Integer
ev.Graphics.MeasureString(resultTextBox.Text.Substring(mStringPos), fnt, _
area, StringFormat.GenericTypographic, chars, _
lines)
Dim rc As New RectangleF(ev.MarginBounds.Left, ev.MarginBounds.Top, _
ev.MarginBounds.Width, ev.MarginBounds.Height)
ev.Graphics.DrawString(resultTextBox.Text.Substring(mStringPos, chars), _
fnt, Brushes.Black, rc, _
StringFormat.GenericTypographic)
mStringPos += chars
ev.HasMorePages = mStringPos < resultTextBox.Text.Length
End Sub
Can someone tell me what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你这样做会发生什么?
这会改变事情吗? (检查我的语法 - 我通常不使用 VB。)
What happens if you do this?
Does that change things? (Check my syntax - I don't typically do VB.)