Windows Develop Bookmark and Share   
 index > Windows Forms Designer > I can't find the AutoSize in the Properties
 

I can't find the AutoSize in the Properties

Hi, I want to set my textBox to be autosize. But I can't find the autosize attribute in the Properties. Is there anything wrong with my visual studio. My version is Visual Studio 2005. Thank you
wideexpress  Thursday, June 28, 2007 12:31 PM

Do you want your text box to resize as the form resizes? If so, the anchor properties will do that automatically for you.

Or are you trying to resize the text box to the size of its contents?

DeborahK  Friday, June 29, 2007 6:25 PM

Even through the property does not appear in the Properties window or in Intellisense (that I can see), it compiles if you just type it in:

Code Snippet

' Add a text string to the TextBox.

TextBox1.Text = "Hello World!"

' Set the size of the TextBox.

TextBox1.AutoSize = True

However, it does not appear to work at one might think it does. It does not resize the textbox width, it resizes the height based on the font. This is from the documentation:

"Gets or sets a value indicating whether the height of the control automatically adjusts when the font assigned to the control is changed. "

DeborahK  Thursday, June 28, 2007 3:50 PM
Also - if you want to write code to automatically size the textbox width, check out the Graphics.MeasureString method.
DeborahK  Thursday, June 28, 2007 3:55 PM

Hi DeborahK

I have tried your method but it doesn't work either. Can you give me any advise to get the size of the form? I think I can compute the size of every component by this. Thanks.

wideexpress  Friday, June 29, 2007 12:31 AM

Do you want your text box to resize as the form resizes? If so, the anchor properties will do that automatically for you.

Or are you trying to resize the text box to the size of its contents?

DeborahK  Friday, June 29, 2007 6:25 PM

You can use google to search for other answers

Custom Search

More Threads

• How to use EnableDesignMode in VS 2005 ??
• How to use pics in Controls
• Create another instance of a Control or Form
• Copy Form Design to another Form or Application?
• New WinForms FAQ repository created
• Automatic toolbox item service ignores ToolboxItem attribute
• Creating Panels when Items are Added in CollectionBase at Designtime
• Loading Design-View in VS2005 fails
• UITypeEditor for properties without a set
• Can a control that uses 'xpFocusProvider' work inside userCtrl?