Home > Net >  Winform C# Application, how do I align text inside a button?
Winform C# Application, how do I align text inside a button?

Time:09-29

I would like to create a button with a plus sign, however when I created the plus sign with the text, it is not alligned from the top of the button as in the image below:

enter image description here

The problem occurs when I try to increase the font size. In default size of the text the plus sign is centered. What can I do to center it in my case?

TextAlign(TopLeft) and UseCompatibleTextRendering didn't worked. (Winform C# Visual Studio 2019)

CodePudding user response:

You can use an png of from resource instead of setting directly the text property of the button.

Example

this.button1.Image = NameSpace1.Properties.Resources.Image2.png;

CodePudding user response:

You can create custom controls and then render the text yourself

https://www.c-sharpcorner.com/UploadFile/f5a10c/creating-custom-controls-in-C-Sharp/

After compiling it should just show up inside the toolbox

  • Related