How do I set a textbox's text to bold at run time?

前端 未结 5 1421
野的像风
野的像风 2020-12-08 12:44

I\'m using Windows forms and I have a textbox which I would occassionally like to make the text bold if it is a certain value.

How do I change the font characteristi

5条回答
  •  星月不相逢
    2020-12-08 13:26

    The bold property of the font itself is read only, but the actual font property of the text box is not. You can change the font of the textbox to bold as follows:

      textBox1.Font = new Font(textBox1.Font, FontStyle.Bold);
    

    And then back again:

      textBox1.Font = new Font(textBox1.Font, FontStyle.Regular);
    

提交回复
热议问题