Windows Develop Bookmark and Share   
 index > Windows Forms General > Calling a Menu Option thru code
 

Calling a Menu Option thru code

I have an application having a Menu with the following options.

File -> a) New b) Open c) Close

There is a button on the form.

My need is when I click on the button, the close option is to be activated.

CyberBhai  Thursday, November 16, 2006 12:14 PM
You should have an event hander for the "Close" menu item. Just let the button's Click event handler call the menu item event handler. For example:

private void closeToolStripMenuItem_Click(object sender, EventArgs e) {
this.Close();
}

private void button1_Click(object sender, EventArgs e) {
closeToolStripMenuItem_Click(sender, e);
}

nobugz  Thursday, November 16, 2006 12:40 PM
You should have an event hander for the "Close" menu item. Just let the button's Click event handler call the menu item event handler. For example:

private void closeToolStripMenuItem_Click(object sender, EventArgs e) {
this.Close();
}

private void button1_Click(object sender, EventArgs e) {
closeToolStripMenuItem_Click(sender, e);
}

nobugz  Thursday, November 16, 2006 12:40 PM

You can use google to search for other answers

Custom Search

More Threads

• Office 12 UI - Yes, a winforms question
• xp visual style in win 2000
• pritnable rectangle
• ListView Help
• (BUG) Text disappear from RichTextBox if RightToLeft is true!!
• threading-debugging problem
• Can't set value of RichTextBox.Lines[index]
• Allowing a form to stop the application shut down procedure
• ToolTipText doesn’t appear in UserControl
• Openfiledialog filter docx files