Solved

Inconsistent fonts in visual basic .net forms

Posted on 2011-03-19
2
890 Views
Last Modified: 2012-05-11
Hi,
I'm developing a VB.NET Windows system in Visual Studio 2008. I have several forms and would like all the text to adjust size using the autoscalemode=FONT property setting.

All of my forms have autoscalemode=FONT, and all components are set to a font size of 8 (same style) but some components are still staying the original size, no matter what. It appears to work fine on one or two screens, then not on others.

The only difference I can see is:

The components (labels, comboboxes, textboxes)  that do not use the autoscalemode=FONT correctly (and default to the size 8 font) show their font property "bolded" in Visual Studio. (click the component, press F4, look at the font settings, the text is bolded)
The Form Font property is also bolded!

The components that are displaying correctly (at run time), are not bolded in Visual Studio. (The form property on these is not bolded.)

Also - I noticed:
In the Designer.vb files, the forms that show correctly ONLY have FONT set for the form - and it's the autoscalemode=font setting.

The other forms have font settings on all of the individual components.

Removing the individual Font settings from the designer did not work - they kept showing back up.

I need consistency across these forms (some of this even happens within the same form ..one component adjusts, the others stay small).

All form components are set to the exact same font style and size.
All forms are set to autoscalemode=FONT.

Is there a property somewhere that overrides the autoscalemode=FONT, that I am missing??
Is this an oddity in Visual Studio 2008?  Is there a fix?

I'd appreciate any input - this needs to go on the user's machine THIS week!

Thanks in advance,
Mary Z
0
Comment
Question by:mz64
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 35175084
1) AutoScaleMode has problems:

WinForms AutoScaleMode - Your One-Way Ticket to Pain & Suffering
http://geekswithblogs.net/codesailor/archive/2007/02/15/106424.aspx

2) Have you tried AutoScaleMode = DPI?  Try a test app to see what the difference is with the problematic controls that you identified.

3) Removing the font from individual components means removing those settings from the .Designer.vb files.  There are two ways to remove, that I know of:  1) highlight the Font settings for each control in the Property Grid, and press the <Del> key to delete any overrides, or (2) open the .Designer.vb files in the code editor, and search for and remove manually.  I prefer #1 for small changes, and #2 for bulk changes.

4) Editing the .Designer files requires a little explanation:

     a) For VB.NET solutions, the .Designer.vb files are not visible unless you check the "Show All Files" option in the Solution Explorer

     b) The font information is set in the InitializeComponent method

        This is a TextBox without a font:

        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(95, 75)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(100, 20)
        Me.TextBox1.TabIndex = 0

        This is a TextBox with a font:

        '
        'TextBox2
        '
        Me.TextBox2.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TextBox2.Location = New System.Drawing.Point(269, 66)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(100, 23)
        Me.TextBox2.TabIndex = 1

        c) Search for and delete any lines for individual controls that have a .Font =
0
 

Author Comment

by:mz64
ID: 35175730
Thanks oh LearnedOne!

I will probably leave it as FONT for now just for consistency's sake. If I have time I may try DPI again (tried it before, but didn't have a desktop to truly see the differences).

This was the ticket to success:
"1) highlight the Font settings for each control in the Property Grid, and press the <Del> key to delete any overrides"
It cleared things out so the autoscalemode could take over.

Yay!
Thank you, Thank you, Thank you!

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question