Solved

Inconsistent fonts in visual basic .net forms

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

11 Experts available now in Live!

Get 1:1 Help Now