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?
If you change AutoSize
property of ToolStripButton to false
, you'll be able to change the width of button.
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.
EDIT:
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);
just
toolStrip1.ImageScalingSize = new Size(40, 40);
That's all ;)
The simplest solution:
Just change the ImageScalingSize property of the Tool Strip on the Property Toolbar.
That's it :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With