The reason for this tutorial:
Feeling like a newbie again after 5 years with VB, .NET poses some obsticals that I certainly was not prepared for.
Changing a font size was quick and easy in VB6, but in the .NET world, it proved itself to be a tedious task. My example is shown below:
I have a solution with a blank form, and at runtime, all controls are dynamically built from a text file and placed in the window.
The problem is that with .NET, all controls like this default to the form's font settings - And MS made the Font property of labels, etc. READ-ONLY.?
In order to accomplish this, you need to create a new font object with your values, and assign it to your (Control).Font property.
This will allow you to change the Font Family, the size in points, and the Bold / Italic etc. properties as well.
As an example, we are defining label "Label1" the Font Family "Arial", 8.25 Points in size, and BOLD.
Label1.Font = New Font("Arial", 8.25, FontStyle.Bold, GraphicsUnit.Point, 0, False)
You could also express it as:
Dim MyFont as New Font("Arial", 8.25, FontStyle.Bold, GraphicsUnit.Point, 0, False)
Label1.Font = MyFont
Label2.Font = MyFont
I hope this helps someone, as I was scratchin' hair out of my head over this. I
knew it could be done.
Funny thing is, it actually was pretty simple! Heh.