Вопрос

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.

Это было полезно?

Решение

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.

Другие советы

Open xyz.designer.cs file, then look for Windows Form Designer generated code after that see for events generated for menustrip items then,

this.menuStripnameToolStripMenuItem.Padding = new System.Windows.Forms.Padding(4, 0, 81, 4);

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top