I have a little problem. I have one 1 RichTextBox and 2 Buttons.
I have that 2 buttons for "toggle Bold FStyle" and "toggle Italic FStyle".
I want to toggle FontStyles without affecting other FontStyles. I hope you understand me.
Below code works when combining FontStyles but is not working when seperating/substracting FontStyles.
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font(richTextBox1.Font, (richTextBox1.SelectionFont.Bold == false ? richTextBox1.SelectionFont.Style | FontStyle.Bold : richTextBox1.SelectionFont.Style));
}
private void button2_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font(richTextBox1.Font, (richTextBox1.SelectionFont.Italic == false ? richTextBox1.SelectionFont.Style | FontStyle.Italic : richTextBox1.SelectionFont.Style));
}
- I make selected text Bold
- I make selected text Italic
- I want to remove Italic while Bold is still active (or opposite)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…