C# Source Codes: Font Dialog

Tuesday, January 26, 2010

Font Dialog









Source Code : Form1.cs

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;

namespace Font_Dialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
FontDialog Fnt = new FontDialog();
Fnt.ShowApply = true;
Fnt.ShowColor = true;
Fnt.Color = (Color)richTextBox1.ForeColor;
Fnt.Font = (Font)richTextBox1.Font;
Fnt.Apply+=new EventHandler(Fnt_Apply);

if (Fnt.ShowDialog() == DialogResult.OK)
{
Change_Font(Fnt);
}
}

private void Change_Font(FontDialog Fnt)
{
richTextBox1.Font = Fnt.Font;
richTextBox1.ForeColor = Fnt.Color;
}

private void Fnt_Apply(object sender, EventArgs e)
{
Change_Font((FontDialog)sender);
}
}
}




Source Code : Form1.Designer.cs

namespace Font_Dialog
{
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///

/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code


private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(70, 213);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(119, 38);
this.button1.TabIndex = 0;
this.button1.Text = "Font ...";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(5, 16);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
this.richTextBox1.Size = new System.Drawing.Size(267, 191);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(281, 255);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.button1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = " Font ...";
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;
private System.Windows.Forms.RichTextBox richTextBox1;
}
}





Download :

exe
http://sites.google.com/site/ogremyfiles/FontDialog_EXE.rar
Source Code
http://sites.google.com/site/ogremyfiles/FontDialog_SourceCode.rar



Designed by : Ogre