Resize Width of MenuStrip

Anil Kocabiyik picture Anil Kocabiyik · Apr 16, 2013 · Viewed 13.3k times · Source

I want to put a gap between menustrip and form at right of menuStrip. I used autosize= false and new size properties, height of menustrip is changed but width is not changed. Menustrip's width remain same with form's width.

menuStrip2.AutoSize = false;
menuStrip2.Size = new Size(50, 90); 

I can not change from Desing-> Properties -> Size, too.

I only create a gap from menustrip's right to form's left.

Answer

MoonKnight picture MoonKnight · Apr 16, 2013

Here's how you do this at design-time:

  1. Create a new form.

  2. place two panels on this form. Call them panelTop and panelFill. Set there dock properties to Top and Fill respectively. Resize panelTop to the height you want you menu strip to be.

  3. Add another panel to panelTop, call it panelTopRight. Dock this panel Right.

  4. Add your menu strip. Set the dock property to fill.

  5. Right click on panelTopRight and 'Send to Back'. Now you can resize the panelTopRight to allow the gap that you require.

If you want to do this at run-time you will have to perform all of the above in code; but that is perhaps another question...

I hope this helps.