You can do something like this
Code Block
void Form9_Load(object sender, EventArgs e)
{
//Font style
System.Drawing.FontFamily[] families = new
System.Drawing.Text.InstalledFontCollection().Families;
foreach (FontFamily ff in families)
{
this.comboBox1.Items.Add(ff.Name);
}
this.comboBox1.SelectedIndex = 0;
//Font size
this.comboBox2.Items.Add(8);
this.comboBox2.Items.Add(9);
this.comboBox2.Items.Add(10);
this.comboBox2.Items.Add(11);
this.comboBox2.Items.Add(12);
this.comboBox2.Items.Add(14);
this.comboBox2.Items.Add(16);
this.comboBox2.Items.Add(18);
this.comboBox2.Items.Add(20);
this.comboBox2.Items.Add(22);
this.comboBox2.Items.Add(24);
this.comboBox2.Items.Add(26);
this.comboBox2.Items.Add(28);
this.comboBox2.Items.Add(36);
this.comboBox2.Items.Add(48);
this.comboBox2.Items.Add(72);
this.comboBox2.SelectedIndex = 0;
this.comboBox1.SelectedIndexChanged +=
new EventHandler(comboBox_SelectedIndexChanged);
this.comboBox2.SelectedIndexChanged +=
new EventHandler(comboBox_SelectedIndexChanged);
}
void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
this.richTextBox1.Focus();
this.richTextBox1.SelectionFont =
new Font(this.comboBox1.SelectedItem.ToString(),
float.Parse(this.comboBox2.SelectedItem.ToString()));
}
|