您的位置:首页 > 编程语言 > C#

c#如何获取当前系统所有的字体和颜色?

2009-12-26 20:26 549 查看
  需要使用using System.Drawing.Text;
    使用如下命令就可以得到当前系统所有字体
InstalledFontCollection MyFont =
new InstalledFontCollection();
   FontFamily[] MyFontFamilies = MyFont.Families;
InstalledFontCollection 对象只看得见在创建它之前安装在 Windows 中的字体。如果用c#创建安装字体程序要使用GDIAddFontResource 函数

 InstalledFontCollection fc = new InstalledFontCollection();
 foreach( FontFamily font in fc.Families )

 {
       ListItem tmp = new ListItem( font.Name , font.Name );
       this.styleFont.Items.Add( tmp );
}

获取系统颜色预定以颜色

Array colors = System.Enum.GetValues( typeof(KnownColor) );
foreach( object colorName in colors )

{
        ListItem tmp = new ListItem( colorName.ToString() , colorName.ToString());
       this.styleColor.Items.Add( tmp );
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# colors windows object