Calculating how big text is.

  • Thread starter Thread starter UJ
  • Start date Start date
U

UJ

I have a small window that contains some text. I want to make the window as
small as possible but still be able to hold all of the text ( the text
changes over time ).

Is there any way I can figure out how wide/tall text label would need to be
to handle the text?

TIA - Jeff.
 
UJ,

Isn't it possible to show the text via Lable with AutoSize set to *true*
when you change the text the size of the Label will change and you can read
the Size prop of the label.

Otherwise there is Graphics.MeasureString method as well as
TextRenderer.MeasureText method (.NET 2.0 only), which more precise than the
Graphics counterpart.
 
Thanks! That worked great.

J.

Stoitcho Goutsev (100) said:
UJ,

Isn't it possible to show the text via Lable with AutoSize set to *true*
when you change the text the size of the Label will change and you can
read the Size prop of the label.

Otherwise there is Graphics.MeasureString method as well as
TextRenderer.MeasureText method (.NET 2.0 only), which more precise than
the Graphics counterpart.
 

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