• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Globally Change Font Settings for Text and Label Controls

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
DeniseGoodheart
Asked:
DeniseGoodheart
  • 2
  • 2
2 Solutions
 
dctuckCommented:
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
 
DeniseGoodheartAuthor Commented:
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
 
dctuckCommented:
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
 
DeniseGoodheartAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now