简体   繁体   English

C#Winform按钮上的困难居中图像

[英]Difficulty Centering Image on C# Winform Button

I'm trying to add a picture to a small button on my winform . 我试图在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 . 该按钮的大小为30 x 24px 24像素,我测得该按钮上的均匀灰色空间为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. 我尝试更改ImageAlign属性的值,以及增大和减小图形的大小,但似乎没有任何效果。 The size of the graphic in the screen capture below is 27 x 21px , which includes a 1px gray border in the graphic. 下面的屏幕截图中图形的大小为27 x 21px ,其中图形中包含1px灰色边框。

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 . 这已经接近我所能达到的程度,但是如您所见,VS并未将图像居中放置在按钮中,而是将其向右下移1px Any thoughts or help here would be great. 任何想法或帮助在这里都是很棒的。 Thanks. 谢谢。

在此处输入图片说明

Play with Padding properties of Button and you will get it center if it is possible. 播放Button Padding属性,如果可能的话,您将使其居中。
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. 可能是我的意思是,例如,如果图像的height为16像素,按钮的height为27,则图像将始终比中心高1像素或比中心低1像素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM