使用 String.Format 格式化的字符串不显示在打印预览中
我正在尝试创建具有相应打印预览的打印功能。由于某种原因,我使用 String.Format 创建的任何字符串都不会显示在打印预览中!使用下面的代码片段作为示例:
Dim strTemp As String
strTemp = String.Format("{0, 210} {1, 75} {2, 51} {3, 200} ",
"NAME", "PRICE", "QUANTITY", "DESCRIPTION")
e.Graphics.DrawString("hi" + strTemp,
New Font("Courier New", 9, FontStyle.Bold),
Brushes.Black, 150, 10)
在此示例中,“hi”将显示在打印预览中,但 strTemp 不会显示。我已经尝试了很多事情 - 使用 ToString 即使它已经是一个字符串,将 String.Format() 调用直接放在 DrawString() 内部,仅举几例。有人能解释一下为什么这不起作用吗?
I'm trying to create a print function with a corresponding print preview. For some reason, any string I create with String.Format will NOT show up on the print preview! Use the code snippet below as an example:
Dim strTemp As String
strTemp = String.Format("{0, 210} {1, 75} {2, 51} {3, 200} ",
"NAME", "PRICE", "QUANTITY", "DESCRIPTION")
e.Graphics.DrawString("hi" + strTemp,
New Font("Courier New", 9, FontStyle.Bold),
Brushes.Black, 150, 10)
In this example, "hi" will display in the print preview, but strTemp will not. I've tried many things - using ToString even though it's already a string, putting the String.Format() call directly inside of DrawString(), just to name a few. Can anybody shed light on why this isn't working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那里有很多空格 - 文本很可能写在图像边界之外,因此不会显示。
You have lots of spaces there - chances are that the text is written outside the image bounds and therefore not showing up.