Home > DeveloperSection > Forums > How to get all font styles from system in c#.net?
Awadhendra Tiwari

Total Post:126

Posted on    August-24-2011 1:07 AM

 C# C# 

 2 Reply(s)
 7123  View(s)
Rate this:
I am implementing a Font Dialog Box application.
I have created 3 list boxes for font family,font style & font size & a text box to display the formatted text.
I have done the coding to get all the font families & to apply them in the text box in the following code:

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
Font f = new Font(listBox1.SelectedItem.ToString(),24);
textBox1.Font = f;

private void Form1_Load(object sender, EventArgs e)
InstalledFontCollection ifc = new InstalledFontCollection();
IEnumerator ie;
ie = ifc.Families.GetEnumerator();
while (ie.MoveNext())

But I am not able to get the system font styles & font sizes to the listbox1 & listbox2
please help me.

James Smith

Total Post:48

Posted on    August-24-2011 6:22 AM

Hi awadhendra,
You can write following line of code to get all system installed fonts.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Text;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            InstalledFontCollection fonts = new InstalledFontCollection();
            for (int i = 0; i < fonts.Families.Length; i++)

Manoj Bhatt
Manoj Bhatt

Total Post:154

Posted on    September-29-2011 3:52 AM

Thanks James.

Don't want to miss updates? Please click the below button!

Follow MindStick