Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering text on a button

I have created two buttons where the .Text property contains characters that I want to center, but I can't get it to work properly. Currently the buttons look like this:

enter image description here

And the code looks like this:

btnUp.Text = "▲";
btnDown.Text = "▼";
btnUp.TextAlign = ContentAlignment.MiddleCenter;
btnDown.TextAlign = ContentAlignment.MiddleCenter;

But what I really want is the Buttons' texts to be centered, so the arrows will be exactly in the middle of the controls. How would I achieve this?

A closer look to show why I am not happy:

enter image description here

Thanks to Thomas Mondel's solution Here is the result:

enter image description here

like image 426
Robin Avatar asked Dec 03 '22 22:12

Robin


1 Answers

You can try to set the UseCompatibleTextRendering property on the buttons to True. It did the trick for me.

UseCompatibleTextRendering

Hope this helps.

like image 191
Thomas Mondel Avatar answered Dec 14 '22 22:12

Thomas Mondel