Solved

Globally Change Font Settings for Text and Label Controls

Posted on 2006-11-30
4
242 Views
Last Modified: 2013-12-03
Hi,

I’m using VS.NET 2005.  The VS.NET font’s settings default is Microsoft Sans Serif, 8.25pt.  Is there a way to globally change the font size and type for all labels and text controls based on a setting or by code?


Thanks,
Denise
0
Comment
Question by:DeniseGoodheart
  • 2
  • 2
4 Comments
 
LVL 7

Assisted Solution

by:dctuck
dctuck earned 500 total points
Comment Utility
Hi Denise,

You change change the font which all controls use on a form by just changing your form's Font property from it's properties window.

0
 

Author Comment

by:DeniseGoodheart
Comment Utility
Hi dctuck:

Thanks for your response.  I understand this is the way to do it individually, but I was curious if it was possible to globally change the font property using some kind of form control collection.  I need to experiment with font sizes for my customer, and I did not want to have to change all the font text controls and labels individually.  It looks like I might have to go into the properties for each form and change it individually, or do something like the following in code:


        Me.txtParameter1.Font.Size = New Size("12")


The code above does not work.  Any suggestion on how to fix it to work?


Thanks,
Denise

0
 
LVL 7

Accepted Solution

by:
dctuck earned 500 total points
Comment Utility
Hi Denise,

The Size property of Font is ReadOnly, so you would have to create a new font to do it that way e.g.:

Me.txtParameter1.Font = New Font("Arial",12)

Another alternative is to create a User setting in the Project Properties page as a System.Drawing.Font type, and set up different fonts in there. Then, from your code you can set the font as (assuming you create the Setting with the name MyFont):

Me.txtParameter1.Font = My.Settings.MyFont

or you can set your controls to use the font in designer view by selecting the Font settings under the (ApplicationSettings) dialog box for the control, which will then automatically bind that controls font to the MyFont font...

Hope that makes sense and helps!

Daniel
0
 

Author Comment

by:DeniseGoodheart
Comment Utility
Hi Daniel,

I tried the following code and it actually globally changed all my form controls, and not just the one mentioned below:

 Me.Font = New Font(Me.txtStockedAS.Text, 11)


It must be some kind of bug.


Many Thanks,
Denise


0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

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

18 Experts available now in Live!

Get 1:1 Help Now