FontStyle is an enumeration you can Or them together to add or Xor to remove.
i.e.
to add underlining to existing style:
textBox1.Font = new Font( textBox1.Font, textBox1.Font.Style | FontStyle.Underline );
to remove underlining from style:
textBox1.Font = new Font( textBox1.Font, textBox1.Font.Style ^ FontStyle.Underline );
and you can check for which Enumerations are in the Font.Style by doing this.
if ((textBox1.Font.Style.HasFlag(FontStyle.Underline))) { textBox1.Font = new Font( textBox1.Font, textBox1.Font.Style ^ FontStyle.Underline ); } else { textBox1.Font = new Font( textBox1.Font, textBox1.Font.Style | FontStyle.Underline ); }
Leave Your Comment