Resizing textboxes

S

Steve

Hi All

I have written some code to rescale my windows forms application forms
depending on the users screen resolution
The application is designed for 1024 x 768 but some customers have 19"
screens and want to use 1280 x 1024 etc

I am using vb.net 2005

Code sample..............................................................
Dim x As Decimal = My.Computer.Screen.Bounds.Width / 1024

Dim y As Decimal = My.Computer.Screen.Bounds.Height / 768

Dim mysizef As New SizeF(x, y)

frm.Scale(mysizef)

.................................................................................................................

This works great for all controls except textboxes

Can someone advise me how to proportion the textboxes to match the other
controls e.g buttons, datagridviews etc

If I resize the font then it affects all the controls and the result is
overlapping controls etc

Regards

Steve
 
G

Guest

Does setting the Multiline property of your textboxes to True accomplish what
you want?
 
L

Linda Liu [MSFT]

Hi Steve,
This works great for all controls except textboxes

Do you mean that the height of the TextBox does not scale properly?

I performed a test and saw that the width of the TextBox is scaled
properly. As for the height of the TextBox, it doesn't change. This is
because the AutoSize property of the TextBox is set to true.

If you set the AutoSize property of the TextBox to false and then scale the
form, the height of the TextBox should be scaled properly.

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu [MSFT]

Hi Steve,

Thank you for your reply!
There is no Autosize property for textboxes

Sorry that I didn't clarify it clearly in my first reply. The TextBoxBase
class has a AutoSize property, which gets or sets a value indicating
whether the height of the control automatically adjusts when the font
assigned to the control is changed. As we all know, the TextBox class is
inherited from the TextBoxBase class, so TextBox inherits the AutoSize
property as well.

Although the AutoSize property of a TextBox is not available in the
Properties window, we can still use this property in code.

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
C

Cor Ligthert[MVP]

Steve,

In my opinion is that very old method you use from the days far behind us.

What you call a 19" screen is something not existing anymore. In the
previous millenium a screen had always the same proportions between height
and width, that is no more in this millenium. So this way will probably keep
you in a way working your program will never fit.

Have a look at anchor and dock properties, when needed you can add extra
panels.

Just my opinion.

Cor
 
S

Steve

Hi Linda

For the life of me I can't find how to do this

There is no Autosize property in intellisense in the code editor.

Can you advise me how to reference the autosize property for existing
textboxes on my windows forms

Regards
Steve
 
L

Linda Liu [MSFT]

Hi Steve,

Thank you for your reply!

You're right that the AutoSize property of a TextBox is not available in
IntelliSense in the code editor. But you can type the line of code, such as
"TextBox1.AutoSize = False" in the code editor directly. When you build the
project, there won't be any compilation error.

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support
 

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