Aracılığıyla paylaş


Menu.MenuItems Özellik

Tanım

Menüyle ilişkili nesne koleksiyonunu MenuItem gösteren bir değer alır.

public:
 property System::Windows::Forms::Menu::MenuItemCollection ^ MenuItems { System::Windows::Forms::Menu::MenuItemCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Menu.MenuItemCollection MenuItems { get; }
[<System.ComponentModel.Browsable(false)>]
member this.MenuItems : System.Windows.Forms.Menu.MenuItemCollection
Public ReadOnly Property MenuItems As Menu.MenuItemCollection

Özellik Değeri

Menu.MenuItemCollection Menüde depolanan nesnelerin listesini MenuItem temsil eden bir.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, MainMenutüretilmiş sınıfının bir örneğini oluşturur ve nesne koleksiyonuna MenuItem bir MenuItem nesne ekler. Bu örnek, bu örnekte tanımlanan yöntemin bir formun sınıfında yer alıp bu form sınıfındaki bir yöntem tarafından çağrılsını gerektirir.

private:
   void InitializeMyMainMenu()
   {
      // Create the MainMenu and the MenuItem to add.
      MainMenu^ mainMenu1 = gcnew MainMenu;
      MenuItem^ menuItem1 = gcnew 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.MenuItems.Add (menuItem1);

   // Assign mainMenu1 to the form.
   this.Menu = mainMenu1;
}
Private Sub InitializeMyMainMenu()
    ' Create the MainMenu and the MenuItem to add.
    Dim mainMenu1 As New MainMenu()
    Dim menuItem1 As 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.
    Me.Menu = mainMenu1
End Sub

Açıklamalar

Şu anda menüde depolanan menü öğeleri listesine başvuru almak için bu özelliği kullanabilirsiniz. ve ContextMenu nesneleri için MainMenu özelliği denetimdeki MenuItems menü yapısının tamamını içerir. MenuItem sınıfı için özelliği ile MenuItems ilişkilendirilmiş alt menü öğelerinin MenuItemlistesini içerir. Menünün menü öğeleri koleksiyonu başvurusuyla (bu özellik tarafından sağlanır), menü öğelerini ekleyip kaldırabilir, toplam menü öğesi sayısını belirleyebilir ve koleksiyondaki menü öğeleri listesini temizleyebilirsiniz. Menü için menü öğesi koleksiyonunu koruma hakkında daha fazla bilgi için belgelere System.Windows.Forms.Menu.MenuItemCollection bakın.

Şunlara uygulanır

Ayrıca bkz.