Solved

Inconsistent fonts in visual basic .net forms

Posted on 2011-03-19
2
889 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now