This article will show you how you can get the collection of
all the fonts install in your machine using c# in windows
application.
Some of my previous articles are as follows: Display
Message With Warning icon in Windows Application Using C#.Net, Display
Message With Warning icon in Windows Application Using C#.Net, Validate
Directory Exist or Not in C#.Net In Windows Application, Image
Save In XML and Load XML Bitmap Image File in Windows Application Using C#.Net,
How
to Save Record in XML File and Read XML to Display in DataGridview Using C#.net
in Windows Application, How
to Add HyperLink and Retrieve Row Value on Link Click in DataGridView #,
Windows application.
So for this article first we will create a new windows
application and add the below code.
Now on button click add the below code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Text;
namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public
Form2()
{
InitializeComponent();
}
private
void button1_Click(object
sender, EventArgs e)
{
string
familyName = "";
FontFamily[]
fontFamilies;
InstalledFontCollection
installedFontCollection = new InstalledFontCollection();
fontFamilies =
installedFontCollection.Families;
int
count = fontFamilies.Length;
for
(int i = 0; i < count; i++)
{
familyName = familyName + "," + fontFamilies[i].Name;
}
textBox1.Text = familyName;
}
}
}
|
In above code first I have retrieve all the font install in
the textbox and after that I have prepare a string to display it in textbox.
Now we have done run the application to check the output.
0 comments:
Please let me know your view