1

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?

Oded
  • 489,969
  • 99
  • 883
  • 1,009
Todd Bauer
  • 219
  • 1
  • 7
  • 15
  • Perhaps the text is written _beyond_ the image bounds. Did you check for that? – Oded Nov 29 '11 at 15:16
  • Gosh, the number of spaces was the problem. Not only did I not know that spacing takes place before each value, I also didn't realize how big the spacing actually is. I feel silly. Thanks for the help - and thanks for the edit, by the way. I'll be sure to use that from now on. :) – Todd Bauer Nov 29 '11 at 15:29

1 Answers1

2

You have lots of spaces there - chances are that the text is written outside the image bounds and therefore not showing up.

Oded
  • 489,969
  • 99
  • 883
  • 1,009