TextBox AutoScale in VS 2005 designer

A

Agata Staniak

I've recently moved to VS 2005 and .NET Framework 2.0 (from VS .NET 2003 and
..NET Framework 1.1). And I have a trivial problem in designer:

1) I create a new project with default settings (C# Windows Application).
OK.
2) And on the main form I put a TextBox. I set its width to 100 pixels. OK
so far.
3) Now I change TextBox font to Courier New, 12pt, bold. OK.
4) I want to set the TextBox'es height to 24 pixels. And I can't. It sets
its height back to 26 pixels.
5) So I want to change the property called AutoSize. TextBox inherits such a
property from TextBoxBase. But it is TextBoxBase's property, not TextBox'es,
so the property window doesn't show it.
6) So I modify the code generated by designer, I add a line:

textbox.AutoSize = false;

and change height to 24. OK, it works for a while. But when designer makes
any changes to code, it removes the line above that I added and returns back
to 26 pixels.

Now what I can do is change the AutoSize property and Height somewhere else
in code, where designer won't mess up. But:

1) It's not optimal to change the control's size twice: once when it is
created with the size forced by designer, and then again change the size to
what I want it to be
2) When I change it in code I lose the possibility to view visually how the
final effect will be, because designer will show something different from
what will be set during runtime. I want to layout controls in designer. I
don't want to set all the sizes and positions at runtime in code without
preview, because it's too much work with over 30 controls. And if I can't do
it in designer, then VS 2005 is a useless tool. I can write code in notepad.
3) I had no such problem in .NET 1.1 and Visual Studio .NET 2003
4) I have no problem with other controls, such as Label, which has a
property AutoSize on its own (not inherited) and I can change that property
in designer's property window, and all works fine.

Any ideas how can I turn off TextBox'es AutoSize property in designer?

Thanks in advance,
Agata Staniak
 
M

Michael.Suarez

I noticed this too..
One workaround (though not ideal), is to set multiline = true... then
you can set height to whatever you want and it will stick.
 

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

Top