Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Remove the spacing at the edges inside a button

Tags:

string

c#

button

Situation: I need a tiny button, with some text on it.

Problem: The button seems to think displaying empty space near its edges is more important than displaying my Text.

I can't for the life of me figure out how to remove that blank stuff at the edges. Any help is greatly appreciated!

Thanks in advance.

-MonsterMaw


2 Answers

Assuming you're talking about WinForms, you can set the FlatStyle property of the button to System.

That will let you resize the button so that it is small enough for the text to fit exacty, without any internal padding.

like image 98
RichieHindle Avatar answered Oct 21 '25 02:10

RichieHindle


You could override the OnPaint method on the button and then draw it however you like. I think you could use the base.OnPaint to draw the button without any text and then draw the text on yourself with pevent.Graphics.DrawString?

like image 22
Filmund Avatar answered Oct 21 '25 02:10

Filmund



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!