Jim Fell
Jim Fell

Reputation: 14256

Difficulty Centering Image on C# Winform Button

I'm trying to add a picture to a small button on my winform. I can add the image alright, but it seems that no matter what I do the image will not center.

The size of the button is 30 x 24px, and I measured the uniform grayspace on the button to be 27 x 21px. I have tried changing the value of the ImageAlign property, as well as increasing and decreasing the size of my graphic, but nothing seems to work. The size of the graphic in the screen capture below is 27 x 21px, which includes a 1px gray border in the graphic.

This is as close as I've been able to get, but as you can see, instead of centering the image in the button, VS has it shifted down and right by 1px. Any thoughts or help here would be great. Thanks.

enter image description here

Upvotes: 1

Views: 1502

Answers (1)

Fabio
Fabio

Reputation: 32445

Play with Padding properties of Button and you will get it center if it is possible.
By possible I mean if for example height of image is 16px and height of button is 27, then image always will be 1px above of center or 1px lower then center.

Upvotes: 1

Related Questions