Right now I am using some buttons with the following code:
richTextBox1.SelectionFont = new Font(\"Tahoma\", 12, FontStyle.Bold);
richTextBox1.SelectionColor = S
This Works for me hope it will help you guys...
private void cmdBold_Click(object sender, EventArgs e)
{
Font new1, old1;
old1 = rtxtBox.SelectionFont;
if (old1.Bold)
new1 = new Font(old1, old1.Style & ~FontStyle.Bold);
else
new1 = new Font(old1, old1.Style | FontStyle.Bold);
rtxtBox.SelectionFont = new1;
rtxtBox.Focus();
}
private void cmdItalic_Click(object sender, EventArgs e)
{
Font new1, old1;
old1 = rtxtBox.SelectionFont;
if (old1.Italic)
new1 = new Font(old1, old1.Style & ~FontStyle.Italic);
else
new1 = new Font(old1, old1.Style | FontStyle.Italic);
rtxtBox.SelectionFont = new1;
rtxtBox.Focus();
}
private void cmdUnderline_Click(object sender, EventArgs e)
{
Font new1, old1;
old1 = rtxtBox.SelectionFont;
if (old1.Underline)
new1 = new Font(old1, old1.Style & ~FontStyle.Underline);
else
new1 = new Font(old1, old1.Style | FontStyle.Underline);
rtxtBox.SelectionFont = new1;
rtxtBox.Focus();
}
Font Size
private void cmbSize_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (float.Parse(cmbSize.Text.Trim()) == 0)
{
MessageBox.Show("Invalid Font Size, it must be Float Number", "Invalid Font Size", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
cmbSize.Text = "10";
return;
}
if (cmbSize.Text.Trim() != "")
{
Font new1, old1;
old1 = rtxtBox.SelectionFont;
new1 = new Font(FontFamily.GenericSansSerif, float.Parse(cmbSize.Text.Trim()), old1.Style);
rtxtBox.SelectionFont = new1;
}
rtxtBox.Focus();
}
}