Sponsored By
Advertise with Us
Advertisement
Advertise with Us
Follow Us
Article
Forum
Blog
Quiz
Beginner
Careers
Contact
Login
Email Id
Password
Remember Me
Forgot Password?
Sign Up
Home
|
Product
|
Services
|
About Us
|
Interview
|
DeveloperSection
|
Submit an Article
|
Submit Blog
Report Abuse Form
Reason:
Home
>>
.Net
>>
C#
>>
How to get all font styles from system in c#.net?
Author
Post
Awadhendra Tiwari
Total Post:
126
Member Since:
1/19/2011
Points:
893
How to get all font styles from system in c#.net?
Posted On:
8/24/2011 1:07:21 AM
Report Abuse
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())
{
listBox1.Items.Add(ie.Current.ToString().Substring(18).TrimEnd(']'));
}
But I am not able to get the system font styles & font sizes to the listbox1 & listbox2
please help me.
Thanks.
Reply
Author
Post
James Smith
Total Post:
48
Member Since:
3/16/2011
Points:
270
Re: How to get all font styles from system in c#.net?
Posted On:
8/24/2011 6:22:29 AM
Report Abuse
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++)
{
Console.WriteLine(fonts.Families[i].Name);
}
}
}
}
Reply
Author
Post
Manoj Bhatt
Total Post:
26
Member Since:
9/29/2011
Points:
132
Re: How to get all font styles from system in c#.net?
Posted On:
9/29/2011 3:52:21 AM
Report Abuse
Thanks James.
Reply
Report Abuse Form
Reason:
Total Online Users:
2607
Advertisement
Advertise with Us
Copyright ©
2009 - 2013
MindStick. All Rights Reserved.
Home
|
Contact Us
|
Services
|
Feedback
|
Advertisement
|
Privacy Policy
|
Term & Conditions
|
About Us