- Back to Home »
- Windows Applications »
- MenuStrip
Posted by :
Sudhir Chekuri
Thursday, 18 February 2016
MenuStrip adds a menu bar at the top of the windows form.
Default Event: Click which is fired when you click on that specific menuitem. Each item will have its own click event.
Steps to create a MenuStrip
Drag and drop a menustrip control to the form which is displayed on the bottom panel of the form but also shows up auto generated textboxes at the top of the form to add items.
You can create the menu items just by adding text in the automatically generated textboxes which are displayed at the top of the form.
Double click on the menu item to see the generated event handler of that specific item and you can create event handler for each item to write some code that has to be executed when you click on that item in the runtime.
Default Event: Click which is fired when you click on that specific menuitem. Each item will have its own click event.
Steps to create a MenuStrip
Drag and drop a menustrip control to the form which is displayed on the bottom panel of the form but also shows up auto generated textboxes at the top of the form to add items.
You can create the menu items just by adding text in the automatically generated textboxes which are displayed at the top of the form.
Double click on the menu item to see the generated event handler of that specific item and you can create event handler for each item to write some code that has to be executed when you click on that item in the runtime.
Example
code to show a message box with the text on the menu item
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(newToolStripMenuItem.Text);
}
private void projectToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(projectToolStripMenuItem.Text);
}