简体   繁体   English

如何使按钮上的图像尺寸变小?

[英]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.

相关问题 如何自动将按钮调整为较小的尺寸? - How to Auto Size a button to smaller size? 如何通过动态更改浏览器大小来使图像自动调整大小? - How can I make an image autosize with the changing of the browser size on the fly? 如何将列表或IEnumerable拆分为N个较小的列表? - How can I split a list or IEnumerable into smaller lists of N size? 如何更改三角形的大小并更改其位置? - How can i change the triangle size to be smaller and change it's location? 如何使图像按钮默认为选中状态 - How can i make an Image button get selected by default 如何使TreeNode的图像显示更小? - how do make the image of TreeNode display smaller? 如何使我的滚动视图/网格中的图像与正常尺寸的屏幕宽度匹配? - How can I make my image inside my scrollview/grid fit to the screen width with it's normal size? 如何通过WPF动画使图像大小增加(给出选择的错觉)? - How can I make an Image grow in size (give the illusion of selection) through a WPF animation? 当javascript事件的大小通过css设置时,如何使图像放大? - How can I make an image enlarge on a javascript event when its size is set through css? 如何使标签页的背景图像散布到可用大小? - How can I make the background-image of a tabpage spread out to the available size?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM