Solved

C# - Populating a MenuStrip with pure code

Posted on 2007-04-03
8
407 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.xltm file opens as .xlsx file 3 37
asp.net bundle 8 36
Long URL in SMS 6 24
index Out OF Range Exception error 4 33
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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

9 Experts available now in Live!

Get 1:1 Help Now