简体   繁体   中英

What is C# equivalent of VB6's Label.FontName?

VB6's Label controls have a Property FontName , which allows you to set the font like this: lblTitle.FontName = "Arial Bold" . Does C# have something similar?

I'm porting a database heavy program from VB6 to C#, and I get names of fonts like "Arial Bold" or "Garamond Italic" from the database and I'm supposed to set the font of some labels based on that text from the database.

Try to do it like this for example:

lblTitle.Font = new Font("Arial", 12, FontStyle.Bold);

To set the font of the label to Arial Bold . In this example with a font size of 12.

You will need to create a new Font and set that in the constructor. then Set the new font to the control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM