Solved

C# - Populating a MenuStrip with pure code

Posted on 2007-04-03
8
409 Views
Last Modified: 2008-02-01
Hi guys 'n gals,

Could somebody please enlighten me in how I would create a MenuStrip in C# with pure code please? So far I have this:

menuStrip1.Items.Add("File");
menuStrip1.Items.Add("Edit");

I have no clue how to add items beneath those, and beneath those, etc...


Could somebody help me out here please?

Cheers!
0
Comment
Question by:Cyber-Drugs
  • 5
  • 3
8 Comments
 
LVL 16

Expert Comment

by:AlexNek
ID: 18847572
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 18847587
Create a menu strip and loook in
private void InitializeComponent()
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18847603
AlexNek,

The link you gave was for MenuItems, rather than MenuStrip...

I didn't think of checking InitializeComponent though, shall give that a go!
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 18849132
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18851050
AlexNek,

Sorry to be a pain, but could you give me an example, let's say I wanted to create

"File" - with "Exit" below it, how would I go about doing this?

Cheers!
0
 
LVL 16

Accepted Solution

by:
AlexNek earned 500 total points
ID: 18851198
Here you are
//from  InitializeComponent()
....
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
...
            //
            // menuStrip1
            //
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(593, 24);
            this.menuStrip1.TabIndex = 5;
            this.menuStrip1.Text = "menuStrip1";
            //
            // fileToolStripMenuItem
            //
            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.openToolStripMenuItem,
            this.closeToolStripMenuItem,
            this.toolStripMenuItem1,
            this.exitToolStripMenuItem});
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
            this.fileToolStripMenuItem.Text = "&File";
            //
            // openToolStripMenuItem
            //
            this.openToolStripMenuItem.Name = "openToolStripMenuItem";
            this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.openToolStripMenuItem.Text = "&Open";
            //
            // closeToolStripMenuItem
            //
            this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
            this.closeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.closeToolStripMenuItem.Text = "&Close";
            //
            // toolStripMenuItem1
            //
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new System.Drawing.Size(149, 6);
            //
            // exitToolStripMenuItem
            //
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.exitToolStripMenuItem.Text = "E&xit";
File
  Open
  Close
----------
   Exit
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18853297
Solved, cheers for your help and patience! :o)
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 18853523
Gratulation! You are welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now