Font name to actual font

pettrer

Well-known member
Joined
Sep 5, 2008
Messages
92
Programming Experience
10+
Hi all,

A quick question!

I need to convert the name of a font to a label's font:

MyLabel.Font = "Algerian"

I've searched the net and tried directcast, typeconverter etc, but can't get it to work. Does anyone know?

Thanks in advance,

Pettrer
 
To create a Font instance use the New keyword and one of the constructors of the Font class. You can choose either one of these: Font Constructor (System.Drawing) for example the Font(String, Single) version where you supply the family name string and the size, click into that help topic and you also get a code sample for free.
 
It worked very nicely. Thanks! (I looked at the entry you descibed before, but couldn't get it to work at that time. If anyone tries to do this, be sure to set the correct attruibutes for the font constructors.)

Thanks again,

Pettrer
 
Back
Top