I am trying to let the fontstyle of a richtextbox be changed to bold with ctrl-b, underlined with ctrl-u, ect. and back by using the hotkey again. Right now changing the fontstyle from regular to bold works fine, but when I change it to bold and then underlined too if I use ctrl-b again it just tries to change it to bold again, which it already is and will not change back to regular. What am I doing wrong?
Here's my code for bold right now:
if (richTextBox1.SelectionFont.Style != FontStyle.Bold)
{
richTextBox1.SelectionFont = new Font("Courier New", 12, FontStyle.Bold | richTextBox1.SelectionFont.Style);
Repository.bold++;
}
else
{
richTextBox1.SelectionFont = new Font("Courier New", 12, FontStyle.Regular);
Repository.bold--;
}

1 answers
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!