"Markus Stoeger" <sp******@gmx.at> ha scritto nel messaggio
news:%2****************@TK2MSFTNGP05.phx.gbl...
VJ wrote: your answer is in your question... the width is the width of the Layout
rectangle...
He wants to get the width+height of _each_ single line, not just the width
of the whole thing. The line "Hello to all" has a bigger width than "the
world.".
Ok, the witdth is not so important to me, so I can simply use something like
MeasureString() to get the maximum width.
For the Height it seems that the best way is the Font.GetHeight(Graphics),
fortunately the height returned is always the total height of a text line,
including the line spacing
(
http://msdn.microsoft.com/library/de...ontmetrics.asp)
Now I found that using the
PrintDocument.PrinterSettings.CreateMeasurementGra phics() sometimes it
return the wong size for MeasureString() wile printing, also if using the
same Graphics object on the PrintPreviewControl works file (e.g. printing
"Label" with Arial 8 in the Rectangle given by MeasureString() I got the
final "l" clipped... bizarre: all say that MeasureString() return a width
that is "oversized").
I wonder if there is a better way to measure text width.
Thanks again.