StrataFrame Forum

How to resize a label to display all the text

http://forum.strataframe.net/Topic11130.aspx

By Greg McGuffey - 8/27/2007

i have a label that holds the name of a process. It is possible that the name is too long to fit in the label. The label is not Autosized, and is anchored on the top, left and right, so it resizes within it's parent container (a splitter panel).



So, I'd like to be able to determine how long the text will be and either make the label larger (which just opens a whole pandoras box of issues, cause then a bunch of other stuff needs to be resized) or some other creative method to deal with this. Any ideas?
By StrataFrame Team - 8/28/2007

Well, you could let it auto-size and put your controls in a TablePanel or FlowLayoutPanel which both handle re-arranging controls when the size of the controls change.  Or, you could just use the System.Drawing.Graphics.MeasureString() method and resize the label manually.  Or, rearrange your form so that you don't have anything to the right of the label (like with localized applications where the label is on top of the textbox rather than to the left of it) and let it grow to the appropriate size (within reason Wink).
By Greg McGuffey - 8/28/2007

Thanks Ben. I mull these options over. BigGrin