There are 3 buttons: bold, italic and underline. Clicking on each of them changes the style of the text. I would like it to be like in a Word: pressing 1 time - a new style appeared, the second time on the same button - disappeared. So there was a problem: how to remove, say, bold type, so that everything else remains as well? I wrote:
if (textBox.Font.Bold) { textBox.Font = new Font(textBox.Font, textBox.Font.Style | FontStyle.Regular); } else { textBox.Font = new Font(textBox.Font, textBox.Font.Style | FontStyle.Bold); } I understand that FontStyle.Regular doesn’t fit, but I don’t know how to write differently, so I dropped it this way. Those. Specifically, in this situation, bold text is added normally, but then not removed.
^ FontStyle.Boldin the first expression instead of| FontStyle.Regular| FontStyle.Regular. - Alexander Petrov