Create a MenuStrip component on a Windows Form
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
Adding a MenuStrip to a Form is a relatively straight forward process. As with all components in .NET there are usually two methods of adding them to your application. Either graphically via the IDE, or manually by adding code.
- To add a menu via the IDE, simply select the
MenuStripcontrol from the Toolbox and click anywhere on theForm. Alternatively, double-click theMenuStripcontrol in the Toolbox. Your form will now look like this.

- To add a menu via code takes a little more work than simply droping a control onto a Form.
First we add a
MenuStripto the Form.private System.Windows.Forms.MenuStrip menuStrip1;
Then in the constructor of the
Form, after the call toInitializeComponent, initialise the instance of theMenuStrip.menuStrip1 = new System.Windows.Forms.MenuStrip();
Also in the constructor, the properties of the
MenuStripneed to be set up.menuStrip1.Location = new System.Drawing.Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Size = new System.Drawing.Size(292, 24); menuStrip1.TabIndex = 0; menuStrip1.Text = "menuStrip1";
Finally, also in the constructor, the
MenuStripis added to the Form'sControlscollection.this.Controls.Add(this.menuStrip1);
Running the application, the Form looks like this.
