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);
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);
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.
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);