text width

  • Thread starter Thread starter Dean L. Howen
  • Start date Start date
D

Dean L. Howen

dear friends,
when drawing string on screen using DrawString, I could get the text height
by calling Font.Height, but how about text width ? Could you tell me?
Thanks.
 
Hi Dean,

To get the text width you need to calculate it based on font and the
graphics object you are drawing on.
The two methods commonly used are Graphics.MeasureString and
Graphics.MeasureCharacterRanges. The first method is easiest to use but
is less accurate. Still in most cases this is sufficient as it should
return a size at least as big as the text.
 
Back
Top