//取消或置为粗体
private void button2_Click(object sender, System.EventArgs e)
{
Font oldFont = this.richTextBox1.SelectionFont;
Font newFont;
if (oldFont.Bold)
newFont = new Font(oldFont,oldFont.Style & ~FontStyle.Bold);
else
newFont = new Font(oldFont,oldFont.Style | FontStyle.Bold);
this.richTextBox1.SelectionFont = newFont;
this.richTextBox1.Focus();
}
//取消或置为斜体
private void button7_Click(object sender, System.EventArgs e)
{
Font oldFont = this.richTextBox1.SelectionFont;
Font newFont;
if (oldFont.Italic)
newFont = new Font(oldFont,oldFont.Style & ~FontStyle.Italic);
else
newFont = new Font(oldFont,oldFont.Style | FontStyle.Italic);
this.richTextBox1.SelectionFont = newFont;
this.richTextBox1.Focus();
}
//取消或加上下划线
private void button8_Click(object sender, System.EventArgs e)
{
Font oldFont = this.richTextBox1.SelectionFont;
Font newFont;
if (oldFont.Underline)
newFont = new Font(oldFont,oldFont.Style & ~FontStyle.Underline);
else
newFont = new Font(oldFont,oldFont.Style | FontStyle.Underline);
this.richTextBox1.SelectionFont = newFont;
this.richTextBox1
.Focus();
}
private void button2_Click(object sender, System.EventArgs e)
{
Font oldFont = this.richTextBox1.SelectionFont;
Font newFont;
if (oldFont.Bold)
newFont = new Font(oldFont,oldFont.Style & ~FontStyle.Bold);
else
newFont = new Font(oldFont,oldFont.Style | FontStyle.Bold);
this.richTextBox1.SelectionFont = newFont;
this.richTextBox1.Focus();
}
//取消或置为斜体
private void button7_Click(object sender, System.EventArgs e)
{
Font oldFont = this.richTextBox1.SelectionFont;
Font newFont;
if (oldFont.Italic)
newFont = new Font(oldFont,oldFont.Style & ~FontStyle.Italic);
else
newFont = new Font(oldFont,oldFont.Style | FontStyle.Italic);
this.richTextBox1.SelectionFont = newFont;
this.richTextBox1.Focus();
}
//取消或加上下划线
private void button8_Click(object sender, System.EventArgs e)
{
Font oldFont = this.richTextBox1.SelectionFont;
Font newFont;
if (oldFont.Underline)
newFont = new Font(oldFont,oldFont.Style & ~FontStyle.Underline);
else
newFont = new Font(oldFont,oldFont.Style | FontStyle.Underline);
this.richTextBox1.SelectionFont = newFont;
this.richTextBox1
.Focus();
}