|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
Menu Classe
Assembly: System.Windows.Forms (em System.Windows.Forms. dll)
public void CreateMyMenu() { // Set the caption for the top-level menu item. menuItem1.Text = "Edit"; // Set the caption for the first submenu. menuItem2.Text = "Font Size"; // Set the caption for menuItem2's first submenu. menuItem3.Text = "Small"; // Set the checked property to true since this is the default value. menuItem3.Checked = true; // Define a shortcut key combination for the menu item. menuItem3.Shortcut = Shortcut.CtrlS; // Set the caption of the second sub menu item of menuItem2. menuItem4.Text = "Large"; // Define a shortcut key combination for the menu item. menuItem4.Shortcut = Shortcut.CtrlL; // Set the index of the menu item so it is placed below the first submenu item. menuItem4.Index = 1; // Add menuItem3 and menuItem4 to menuItem2's list of menu items. menuItem2.MenuItems.Add(menuItem3); menuItem2.MenuItems.Add(menuItem4); // Add menuItem2 to menuItem1's list of menu items. menuItem1.MenuItems.Add(menuItem2); // Add menuItem1 to the MainMenu for displaying. mainMenu1.MenuItems.Add(menuItem1); }
public void CreateMyMenu()
{
// Set the caption for the top-level menu item.
menuItem1.set_Text("Edit");
// Set the caption for the first submenu.
menuItem2.set_Text("Font Size");
// Set the caption for menuItem2's first submenu.
menuItem3.set_Text("Small");
// Set the checked property to true since this is the default value.
menuItem3.set_Checked(true);
// Define a shortcut key combination for the menu item.
menuItem3.set_Shortcut(Shortcut.CtrlS);
// Set the caption of the second sub menu item of menuItem2.
menuItem4.set_Text("Large");
// Define a shortcut key combination for the menu item.
menuItem4.set_Shortcut(Shortcut.CtrlL);
// Set the index of the menu item so it is placed below
//the first submenu item.
menuItem4.set_Index(1);
// Add menuItem3 and menuItem4 to menuItem2's list of menu items.
menuItem2.get_MenuItems().Add(menuItem3);
menuItem2.get_MenuItems().Add(menuItem4);
// Add menuItem2 to menuItem1's list of menu items.
menuItem1.get_MenuItems().Add(menuItem2);
// Add menuItem1 to the MainMenu for displaying.
mainMenu1.get_MenuItems().Add(menuItem1);
} //CreateMyMenu