How to get a font's name and its styles?
I have two Comboboxes: [_cmbxFontName, _cmbxStyleName]
I can load all installed fonts into _cmbxFontName
, but I could not load fonts styles. If I select a font name in _cmbxFontName
, then the other _cmbxstyleName
combobox wants to load its styles. for example" [Regular, Normal, Bold, Italic, etc].
I know all fonts have di开发者_如何学Gofferent styles but how can I find and load them?
You can use the System.Drawing.FontStyle enumeration to list the styles. I think you can specify any style in FontStyle for any font when the font is created.
New Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Bold)
You can load the font styles into a combo box like this:
Dim styles() As FontStyle
Dim style As FontStyle
styles = System.Enum.GetValues(GetType(FontStyle))
For Each style In styles
combobox1.items.add(style.ToString)
Next style
精彩评论