[英]How can I make the image size smaller on a button?
I have a button and I want image (.ico file) and text to exist on it.我有一个按钮,我想要图像(.ico 文件)和文本存在于它上面。 My problem is that I want button's height to be small, but I can't manage to "shrink" the image as much as I want to.
我的问题是我希望按钮的高度很小,但我无法像我想要的那样“缩小”图像。 The result is to have a piece of image visible on the button and not the hole image.
结果是在按钮上显示了一块图像,而不是孔图像。 At the image property the image size is fixed (48x48) and the option is grey so I can't change it.
在图像属性中,图像大小是固定的 (48x48),并且该选项是灰色的,因此我无法更改它。 How can I make this image to be 16x16?
我怎样才能使这个图像成为 16x16?
Try buttonname.BackgroundImageLayout = ImageLayout.Stretch;
试试
buttonname.BackgroundImageLayout = ImageLayout.Stretch;
or change this property in designer.或在设计器中更改此属性。
My solution was to use an ImageList control.我的解决方案是使用 ImageList 控件。 You can define the size the images are to be displayed (eg I set the ImgageList ImageSize property to 16x16) and then set the button.ImageList and ImageIndex properties instead of the Image property.
您可以定义要显示的图像的大小(例如,我将 ImgageList ImageSize 属性设置为 16x16),然后设置 button.ImageList 和 ImageIndex 属性而不是 Image 属性。
I think if you use the Paint event of the Button you can draw any image in any size that you want.我认为如果您使用 Button 的Paint 事件,您可以绘制任何您想要的任何大小的图像。 if it isn't possible to re-size the image you can do that in this way.
如果无法重新调整图像大小,您可以通过这种方式进行调整。
如果您使用 DevExpress 简单按钮,您应该设置 BackgroundImageLayout = ImageLayout.Zoom 并将按钮的背景色设置为透明(从Appereance->Backcolor )
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(30, 30); // specify size you want
If you have the Image with size 16*16 then set these Button properties at design time.如果您有大小为 16*16 的图像,则在设计时设置这些 Button 属性。 1) TextImageRelation - ImageBeforeText 2) TextAlign - MiddleRight 3) ImageAlign - MiddleLeft 4) Set the
1) TextImageRelation - ImageBeforeText 2) TextAlign - MiddleRight 3) ImageAlign - MiddleLeft 4) 设置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.