Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the size of the buttons on a tool strip?

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?

like image 780
ghd Avatar asked Aug 07 '10 21:08

ghd


3 Answers

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);
like image 96
Ondra C. Avatar answered Nov 09 '22 13:11

Ondra C.


just

toolStrip1.ImageScalingSize = new Size(40, 40);

That's all ;)

like image 27
Dmitriy Avatar answered Nov 09 '22 14:11

Dmitriy


The simplest solution:

Just change the ImageScalingSize property of the Tool Strip on the Property Toolbar.

That's it :)

like image 2
RustanTech Avatar answered Nov 09 '22 14:11

RustanTech