Solved

Globally Change Font Settings for Text and Label Controls

Posted on 2006-11-30
4
247 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
[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
  • 2
4 Comments
 
LVL 7

Assisted Solution

by:dctuck
dctuck earned 500 total points
ID: 18053345
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
ID: 18055072
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
ID: 18055444
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
ID: 18055477
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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