Load all system installed fonts : Font « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » FontScreenshots 
Load all system installed fonts
Load all system installed fonts


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

public class Form1 : Form
{
  private System.Windows.Forms.GroupBox groupBox1;
  private System.Windows.Forms.ComboBox lstFonts;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.StatusStrip statusBar;
  private System.Windows.Forms.ToolStripStatusLabel statusLabel;

  public Form1() {
        InitializeComponent();
    System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
    foreach (FontFamily family in fonts.Families)
    {
      lstFonts.Items.Add(family.Name);
    }
  }

  private void lstFonts_SelectedIndexChanged(object sender, EventArgs e)
  {
        this.Invalidate();
  }

  private void Form1_Paint(object sender, PaintEventArgs e)
  {
    if (lstFonts.SelectedIndex != -1)
    {
            e.Graphics.DrawString(lstFonts.Text, new Font(lstFonts.Text, 50), Brushes.Black, 1050);
            statusBar.Items[0].Text = lstFonts.Text;
    }
  }

  private void InitializeComponent()
  {
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.lstFonts = new System.Windows.Forms.ComboBox();
    this.label1 = new System.Windows.Forms.Label();
    this.statusBar = new System.Windows.Forms.StatusStrip();
    this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
    this.groupBox1.SuspendLayout();
    this.statusBar.SuspendLayout();
    this.SuspendLayout();
    // 
    // groupBox1
    // 
    this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
          | System.Windows.Forms.AnchorStyles.Right)));
    this.groupBox1.Controls.Add(this.lstFonts);
    this.groupBox1.Controls.Add(this.label1);
    this.groupBox1.Location = new System.Drawing.Point(70);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(49740);
    this.groupBox1.TabIndex = 1;
    this.groupBox1.TabStop = false;
    // 
    // lstFonts
    // 
    this.lstFonts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    this.lstFonts.DropDownWidth = 340;
    this.lstFonts.FormattingEnabled = true;
    this.lstFonts.Location = new System.Drawing.Point(10012);
    this.lstFonts.Name = "lstFonts";
    this.lstFonts.Size = new System.Drawing.Size(34021);
    this.lstFonts.TabIndex = 1;
    this.lstFonts.SelectedIndexChanged += new System.EventHandler(this.lstFonts_SelectedIndexChanged);
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(1216);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(8012);
    this.label1.TabIndex = 0;
    this.label1.Text = "Choose Font:";
    // 
    // statusBar
    // 
    this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.statusLabel});
    this.statusBar.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Table;
    this.statusBar.Location = new System.Drawing.Point(0155);
    this.statusBar.Name = "statusBar";
    this.statusBar.Size = new System.Drawing.Size(51622);
    this.statusBar.TabIndex = 2;
    this.statusBar.Text = "statusStrip1";
    // 
    // statusLabel
    // 
    this.statusLabel.Name = "statusLabel";
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(516177);
    this.Controls.Add(this.groupBox1);
    this.Controls.Add(this.statusBar);
    this.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.Text = "Font Viewer";
    this.groupBox1.ResumeLayout(false);
    this.statusBar.ResumeLayout(false);
    this.ResumeLayout(false);
    this.PerformLayout();

  }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}


           
       
Related examples in the same category
1.All font properties
2.new Font("Times New Roman", 10, FontStyle.Italic)
3.new Font(strFont, fSize)
4.new Font(fontRegular, FontStyle.Italic);
5.Text on Baseline
6.Font: SizeInPoints
7.Font with different size
8.Font: GetHeight
9.System Fonts: Icon Title FontSystem Fonts: Icon Title Font
10.Timer based animation for fontTimer based animation for font
11.Get all system installed fontGet all system installed font
12.Font listFont list
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.