PDA

View Full Version : دسترسی به فونت در C#.net



iman-63
چهارشنبه 20 خرداد 1388, 11:33 صبح
سلام به دوستان عزیز.
برای دسترسی به فونت های سیتم آیا به غیر از Font Dialog راه دیگر چیست.
به تصویری که گذاشتم یه نگاهی بندازین تا منظورم رو بهتر بفهمین.
با تشکر

mohsen_csharp
چهارشنبه 20 خرداد 1388, 12:52 عصر
با سلام

private void Form1_Load(object sender, EventArgs e)
{
foreach (FontFamily ff in FontFamily.Families)
{
comboBox1.Items.Add(ff.Name);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
FontFamily ff = new FontFamily(comboBox1.Text);
if (ff.IsStyleAvailable(FontStyle.Regular))
{
textBox1.Font = new Font(ff, 10, FontStyle.Regular);
}
else if (ff.IsStyleAvailable(FontStyle.Bold))
{
textBox1.Font = new Font(ff, 10, FontStyle.Bold);
}
else if (ff.IsStyleAvailable(FontStyle.Italic))
{
textBox1.Font = new Font(ff, 10, FontStyle.Italic);
}
else if (ff.IsStyleAvailable(FontStyle.Strikeout))
{
textBox1.Font = new Font(ff, 10, FontStyle.Strikeout);
}
else if (ff.IsStyleAvailable(FontStyle.Underline))
{
textBox1.Font = new Font(ff, 10, FontStyle.Underline);
}
}
خودت می تونی سایزش رو درست کنی