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
Este tópico ainda não foi avaliado como - Avalie este tópico

Menu.MenuItems Propriedade

Gets a value indicating the collection of MenuItem objects associated with the menu.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (em System.Windows.Forms. dll)
[BrowsableAttribute(false)]
public Menu..::.MenuItemCollection MenuItems { get; }

Valor da propriedade

Tipo: System.Windows.Forms.Menu.MenuItemCollection
A System.Windows.Forms.Menu.MenuItemCollection that represents the list of MenuItem objects stored in the menu.

Você pode utilizar essa propriedade para obter uma referência à lista de itens Menu que atualmente são armazenados no menu.For MainMenu and ContextMenu objects, the MenuItems property contains the entire menu structure in the control.For the MenuItem class, the MenuItems property contains the list of submenu items associated with the MenuItem.Com a referência à coleção de itens de menu para o menu (fornecido por essa propriedade), você pode adicionar e remover itens de menu, determinar o número total de itens de menu e limpar a lista de itens de menu da coleção.For more information on maintaining the menu item collection for a menu, see the System.Windows.Forms.Menu.MenuItemCollection documentation.

The following code example creates an instance of the derived class, MainMenu, and adds a MenuItem object to its collection of MenuItem objects.Este exemplo requer que o método definido neste exemplo está localizado na classe de um formulário e chamado por um método na classe desse formulário.

private void InitializeMyMainMenu()
{
   // Create the MainMenu and the MenuItem to add.
   MainMenu mainMenu1 = new MainMenu();
   MenuItem menuItem1 = new MenuItem("&File");

   /* Use the MenuItems property to call the Add method
      to add the MenuItem to the MainMenu menu item collection. */
   mainMenu1.MenuItems.Add (menuItem1);

   // Assign mainMenu1 to the form.
   this.Menu = mainMenu1;
}



private void InitializeMyMainMenu()
{
    // Create the MainMenu and the MenuItem to add.
    MainMenu mainMenu1 = new MainMenu();
    MenuItem menuItem1 = new MenuItem("&File");

    /* Use the MenuItems property to call the Add method
       to add the MenuItem to the MainMenu menu item collection.
     */
    mainMenu1.get_MenuItems().Add(menuItem1);

    // Assign mainMenu1 to the form.
    this.set_Menu(mainMenu1);
} //InitializeMyMainMenu


Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

ADICIONAR
© 2013 Microsoft. Todos os direitos reservados.