Solved

Inconsistent fonts in visual basic .net forms

Posted on 2011-03-19
2
897 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I figure out a “DependencyProperty.UserValue” exception in my WPF/MVVM application? 1 23
SSRS Deployment problem 5 96
linq, c# 8 34
TFS 2015 Access denied. 1 30
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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