专注于高品质PHP技术等信息服务于一体 [STIEMAP] [RSS]

百度提供的广告:
c#
当前位置:首页 > 技术文档 > c# >  > 
toolStripComboBox 添加项 获得系统安装字体

        private void FormPrint_Load(object sender, EventArgs e)
        {
            SetFonts();
        }

        #region 私有方法
        private void SetFonts()
        {
            InstalledFontCollection fc = new InstalledFontCollection(); //获得系统安装字体,注意中文排在下面,所以下面使用 for 循环反向添加到 toolStripComboBox  中。
            int len = fc.Families.Length;
            for (int i = len-1; i >= 0;i-- )
            {
                fonts.Items.Add(fc.Families[i].Name);
            }
        }
        #endregion

如果想设置 toolStripComboBox  默认选择的项,这个就非常简单了 fonts.text = "宋体"; 即可