Hi,
MenuStrip Control.
The Windows MenuStrip control provides an application menu system. The menustrip
works with both Single document interfaces SDI and Multiple document interfaces
MDI. With MDI applications the MenuStrip can be configured to merge with the main
form for better navigation.
Namespace: System.Windows.Forms
Assembly: Systems.Windows.Forms.dll
using System.Windows.Forms;
Calling: System.Windows.Forms.MenuStrip
Adding a MenuStrip to a Form.
Using VisualStudio, adding a MenuStrip and ToolStripMenuItem is quick and easy.
With a form open in design view, double click the MenuStrip item on the toolbox.
This will add the MenuStrip control to the form. To add ToolStripMenuItem, simply
start building your menu structure.
To add a MenuStrip writing code.
Create the MenuStrip control and add it to the forms.
MenuStrip MainMenu = new MenuStrip();
this.Controls.Add(MainMenu);
Add the File menu Item and add it to the MenuStrip above.
ToolStripMenuItem File = new ToolStripMenuItem("File"); MainMenu.Items.Add(File);
Create the New menu Items and add it to the FileMenu above. We are also going to
create the click event for the item.
ToolStripMenuItem New = new ToolStripMenuItem("New");
New.Click += new EventHandler(New_Click);
File.DropDownItems.Add(New);
Create the Open menu Item and ad it to the FileMenu as you did above.
ToolStripMenuItem Open = new ToolStripMenuItem("Open");
Open.Click += new EventHandler(Open_Click);
File.DropDownItems.Add(Open);
Carry on in this manner to complete your menu structure. We now need to respond
to the click events we created earlier.
void New_Click(object sender, EventArgs e) { MessageBox.Show(sender.ToString());
}
void Open_Click(object sender, EventArgs e) { MessageBox.Show(sender.ToString());
}
Hope this will help you