Sunday 1 May 2011

System Font Name List in Combobox in Win Forms


System Font Name List in Combobox in Win Forms:-




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D ;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication8
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           


        }

        private void button1_Click(object sender, EventArgs e)
        {
            FontFamily[] fonts;
            fonts = FontFamily.Families;
            foreach (FontFamily font in fonts)
               {
                comboBox2.Items.Add(font.Name);
               }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            InstalledFontCollection fonts = new InstalledFontCollection();
            for (int i = 0; i < fonts.Families.Length; i++)
            {
                comboBox1.Items.Add(fonts.Families[i].Name);
            }
        }
    }
}

No comments:

Post a Comment