0

I have a button with text "button changeme". If i would like to change the font of "changeme" to size 40, how would i do so?

At the moment I have this code:

button1.Font = new Font(button1.Font.FontFamily, 40);
O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
user1920206
  • 69
  • 10
  • Check out these answers: [Different fonts in one label][1] and [Formatting text in a winform label][2] [1]: http://stackoverflow.com/questions/7358654/different-fonts-in-one-label [2]: http://stackoverflow.com/questions/11311/formatting-text-in-winform-label – Chris Ayers Jan 22 '13 at 16:32

2 Answers2

4

I would recommend creating a sub-class of the Button class and overriding the OnPaint method to manually output the text. The default Button class does not support this functionality.

I would recommend for further research you check out the VisualStyleRenderer class which will be useful for drawing the button background. There may be easier ways to do this that avoid having to redraw the entire button, but using the VisualStyleRenderer is not particularly onerous, and will give you the greatest amount of flexibility.

Brett Wolfington
  • 6,587
  • 4
  • 32
  • 51
0

I would recommend you to use this code it may help you to solve this issue.Please try this code :

this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F);
Asif Rashid
  • 15
  • 1
  • 4