如何增加工具条上按钮的大小? [英] How to increase the size of the buttons on a tool strip?

查看:52
本文介绍了如何增加工具条上按钮的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在表单中添加了一个工具条.在此工具条中,借助添加工具条按钮,我有一些按钮.这些按钮的默认大小为22、20.但是我想将按钮的大小更改为25、50.我通过更改size属性在设计器中进行了更改,但未在我的表单中反映出来.即使我改变工具条的高度,也不会改变.有什么帮助吗?

I have added a tool strip to my form. In this tool strip i had some buttons with the help of add toolstrip button. These buttons are by default of the size 22, 20. But i want to change the size of the button to 25, 50. I made changes in designer by changing the size property but it is not reflected in my form. Even if i change the height of the tool strip, it is not getting changed. Any help with that?

推荐答案

如果将ToolStripButton的 AutoSize 属性更改为 false ,则可以更改宽度按钮.

If you change AutoSize property of ToolStripButton to false, you'll be able to change the width of button.

如果将ToolStrip的 AutoSize 属性更改为 false ,则可以更改其高度,并且ToolStripButton会自动更改其高度以适合工具条

If you change AutoSize property of ToolStrip to false, you'll be able to change its height and the ToolStripButton will change its height automatically to fit into the tool strip.

如果不仅要增加按钮的大小,而且要增加按钮图像的大小,则必须使用较大的图像,或者可以尝试调整原始图像的大小.然后,您还必须更改toolstrip的 ImageScalingSize 属性.尝试使用以下代码:

If you want to increase not only size of the button, but also the size of the button image, you must either use the bigger image, or you can try to resize the original one. Then you must also change toolstrip's ImageScalingSize property. Try to use the following code:

//change the dimensions of button itself
toolStrip1.AutoSize = false; toolStrip1.Height = 50;
toolStripButton1.AutoSize = false; toolStripButton1.Width = 50;

//resize the image of the button to the new size
int sourceWidth = toolStripButton1.Image.Width;
int sourceHeight = toolStripButton1.Image.Height;
Bitmap b = new Bitmap(40, 40);
using (Graphics g = Graphics.FromImage((Image)b))
{
   g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
   g.DrawImage(toolStripButton1.Image, 0, 0, 40, 40);
}
Image myResizedImg = (Image)b;

//put the resized image back to the button and change toolstrip's ImageScalingSize property 
toolStripButton1.Image = myResizedImg;
toolStrip1.ImageScalingSize = new Size(40, 40);

这篇关于如何增加工具条上按钮的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆