By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,567 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,567 IT Pros & Developers. It's quick & easy.

Resizing textboxes

P: n/a
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
Sep 18 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Does setting the Multiline property of your textboxes to True accomplish what
you want?

"Steve" wrote:
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
Sep 18 '07 #2

P: n/a
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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Sep 18 '07 #3

P: n/a
Hi Linda

There is no Autosize property for textboxes

Regards
Steve

"Linda Liu [MSFT]" <v-****@online.microsoft.comwrote in message
news:Zz***************@TK2MSFTNGHUB02.phx.gbl...
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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Sep 18 '07 #4

P: n/a
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

Sep 19 '07 #5

P: n/a
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

"Steve" <ga*****@nospam.nospamschreef in bericht
news:e4****************@TK2MSFTNGP02.phx.gbl...
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

Sep 19 '07 #6

P: n/a
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

"Linda Liu [MSFT]" <v-****@online.microsoft.comwrote in message
news:6l****************@TK2MSFTNGHUB02.phx.gbl...
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

Sep 20 '07 #7

P: n/a
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

Sep 20 '07 #8

P: n/a
Linda

Thank you. You learn something every day

regards
steve

"Linda Liu [MSFT]" <v-****@online.microsoft.comwrote in message
news:I9****************@TK2MSFTNGHUB02.phx.gbl...
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

Sep 20 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.