tags:

views:

38

answers:

2

Hi,

I have a textbox which must be disabled on my page. However, the text in the textbox is larger than the size of the textbox. As the scrollbars for the textbar are therefore disabled, I need the textbox to automatically resize and therefore resize its parent form too.

Is this possible? If so, how?

+2  A: 

You can achieve this by using Graphics.MeasureString and setting the size measured with this method. Although you really should think about using a Label control

Scoregraphic
And when using Windows.Forms, one can also use the [TextRenderer](http://msdn.microsoft.com/en-us/library/system.windows.forms.textrenderer.aspx) class
Patrick
Agree, a label styled to look like a disabled text box would be much nicer.
Michael
+1  A: 

I prefer using the ReadOnly property rather than disabling the text box. The user can still get to all of the text and they can copy it to the clipboard if desired.

NascarEd