Solved

Globally Change Font Settings for Text and Label Controls

Posted on 2006-11-30
4
245 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
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 Populate DataModel with DataTable 44 38
Crystal reports vb.net 2 54
Open a link in vb.net 2 16
Groupbox Control ? 2 19
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 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