Font list form : Font « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » Font 
23.70.8.Font list form
Font list form
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Text;
using System.Collections.Generic;

public class FontListForm : Form
{
    public FontListForm()
    {
        InitializeComponent();
    }

    private void FontListForm_Load(object sender, EventArgs e)
    {
        using (InstalledFontCollection fontFamilies = new InstalledFontCollection())
        {
            int offset = 10;
            foreach (FontFamily family in fontFamilies.Families)
            {
                try
                {
                    Label fontLabel = new Label();
                    fontLabel.Text = family.Name;
                    fontLabel.Font = new Font(family, 14);
                    fontLabel.Left = 10;
                    fontLabel.Width = pnlFonts.Width;
                    fontLabel.Top = offset;

                    pnlFonts.Controls.Add(fontLabel);
                    offset += 30;
                }catch{}
            }
        }
    }
    private System.ComponentModel.IContainer components = null;

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
        this.pnlFonts = new System.Windows.Forms.Panel();
        this.SuspendLayout();

        this.pnlFonts.AutoScroll = true;
        this.pnlFonts.Dock = System.Windows.Forms.DockStyle.Fill;
        this.pnlFonts.Location = new System.Drawing.Point(00);
        this.pnlFonts.Name = "pnlFonts";
        this.pnlFonts.Size = new System.Drawing.Size(299276);
        this.pnlFonts.TabIndex = 0;

        this.ClientSize = new System.Drawing.Size(299276);
        this.Controls.Add(this.pnlFonts);
        this.Name = "FontListForm";
        this.Text = "List of Installed Fonts";
        this.Load += new System.EventHandler(this.FontListForm_Load);
        this.ResumeLayout(false);

    }

    private System.Windows.Forms.Panel pnlFonts;
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new FontListForm());
    }
    
}
23.70.Font
23.70.1.Font Constructor: derive a fontFont Constructor: derive a font
23.70.2.RichTextBox: MultilineRichTextBox: Multiline
23.70.3.Create a font from font name and size
23.70.4.Create a font from FontFamilyCreate a font from FontFamily
23.70.5.Use GraphicsUnit to create fontUse GraphicsUnit to create font
23.70.6.List all Font FamiliesList all Font Families
23.70.7.Font PropertiesFont Properties
23.70.8.Font list formFont list form
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.