FontFamily and FontStyle strings

aronmatthew

Well-known member
Joined
Aug 5, 2019
Messages
77
Programming Experience
Beginner
I having a problem with the following code throwing ArgumentException [FontFamily: Name=Microsoft Sans Serif] cannot be found.

new FontFamily(FontFamily.GenericSansSerif.ToString());
 
ToString returns a description including the name, but the constructor expects only the name, for that you can use the Name property.
Although why not use FontFamily.GenericSansSerif property directly which returns the FontFamily instance?
 
Back
Top Bottom