问题描述
|
我有2个组合框[_cmbxFontName,_cmbxStyleName]
我可以将所有已安装的字体加载到_cmbxFontName中。但我无法加载字体样式。如果我在_cmbxFontName中选择字体名称,则另一个_cmbxstyleName组合框要加载其样式[Regular,Normal,Bold,Italic ......]。
我知道所有字体都有不同的样式,但是如何找到并加载它。
谢谢.............![在此处输入图片描述] [1]
解决方法
您可以使用System.Drawing.FontStyle枚举列出样式。我认为您可以在创建字体时为任何字体指定FontStyle中的任何样式。
New Font(FontFamily.GenericSansSerif,12.0F,FontStyle.Bold)
您可以像这样将字体样式加载到组合框中:
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