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?
A:
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);
Graphics g = Graphics.FromImage((Image)b);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(toolStripButton1.Image, 0, 0, 40, 40);
g.Dispose();
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);
Ondra C.
2010-08-07 21:35:54
I already did that but no use!
ghd
2010-08-08 02:10:02
Well, it changes the size of the toolstripbutton, as you wanted... So I guess what you really want to do is to resize also the image button... I've edited my answer...
Ondra C.
2010-08-08 07:02:10
Thanks! It worked. Is it possible to have two tool strips one over another in one form at the right end of the form?
ghd
2010-08-09 06:25:11
I undocked the toolstrip but now the buttons on the tool strip have disappeared. They appear only when i click on the small arrow at the bottom. Any idea please?
ghd
2010-08-09 07:55:21