Autoscale Font in a TextBox Control so that its as big as possible and still fits in text area bound

Posted by blak3r on Stack Overflow See other posts from Stack Overflow or by blak3r
Published on 2009-04-26T23:32:46Z Indexed on 2010/03/12 19:57 UTC
Read the original article Hit count: 214

Filed under:
|
|

I need a TextBox or some type of Multi-Line Label control which will automatically adjust the font-size to make it as large as possible and yet have the entire message fit inside the bounds of the text area.

I wanted to see if anyone had implemented a user control like this before developing my own.

Example application: have a TextBox which will be half of the area on a windows form. When a message comes in which is will be approximately 100-500 characters it will put all the text in the control and set the font as large as possible. An implementation which uses Mono Supported .NET libraries would be a plus.

Thanks in advance.

If know one has implemented a control already... If someone knows how to test if a given text completely fits inside the text area that would be useful for if I roll my own control.

Edit: I ended up writing an extension to RichTextBox. I will post my code shortly once i've verified that all the kinks are worked out.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET