Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top