Hi,
MeasureString add a little spaces:
FROM MSDN:
The MeasureString method is designed for use with individual strings and
includes a small amount of extra space before and after the string to allow
for overhanging glyphs. Also, the DrawString method adjusts glyph points to
optimize display quality and might display a string narrower than reported
by MeasureString. To obtain metrics suitable for adjacent strings in layout
(for example, when implementing formatted text), use the
MeasureCharacterRanges method.
Now if the Graphics class passed to the method are different you may get
different results, the one from the Panel refer to the display and the one
from the PrintEventArgs refer to the printer.
My advice is to try the MeasureCharacterRanges.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Yaron" <Ya***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
Hi,
I made a procedure which receives a Graphics parameter, and with that
Graphics parameter, performs various things. The area of confusion here is
that when I pass the procedure a Graphics object created by a Panel, and use
the MeasureString() method, I get a different width than when I pass up the
procedure a Graphics object created by a PrintDocument.
The procedure is exactly the same, independent of which object called it,
so why would the MeasureString width be different? It's not different by a
lot, maybe off by 5 or 10, but its still enough to screw up my code...
Yaron