本文整理汇总了C#中System.Windows.Forms.MenuItem.PerformSelect方法的典型用法代码示例。如果您正苦于以下问题:C# MenuItem.PerformSelect方法的具体用法?C# MenuItem.PerformSelect怎么用?C# MenuItem.PerformSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MenuItem
的用法示例。
在下文中一共展示了MenuItem.PerformSelect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMyMenu
public void CreateMyMenu()
{
// Create a main menu object.
MainMenu mainMenu1 = new MainMenu();
// Create empty menu item objects.
MenuItem menuItem1 = new MenuItem();
MenuItem menuItem2 = new MenuItem();
// Set the caption of the menu items.
menuItem1.Text = "&File";
menuItem2.Text = "&Edit";
// Add the menu items to the main menu.
mainMenu1.MenuItems.Add(menuItem1);
mainMenu1.MenuItems.Add(menuItem2);
// Add functionality to the menu items.
menuItem1.Select += new System.EventHandler(this.menuItem1_Select);
menuItem2.Select += new System.EventHandler(this.menuItem2_Select);
// Assign mainMenu1 to the form.
this.Menu=mainMenu1;
// Select the File menu item.
menuItem1.PerformSelect();
}
private void menuItem1_Select(object sender, System.EventArgs e)
{
MessageBox.Show("You selected the File menu.","The Event Information");
}
private void menuItem2_Select(object sender, System.EventArgs e)
{
MessageBox.Show("You selected the Edit menu.","The Event Information");
}