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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top