Freigeben über


MenuItem.IsParent-Eigenschaft

Ruft einen Wert ab, der angibt, ob das Menüelement untergeordnete Menüelemente enthält.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Overrides ReadOnly Property IsParent As Boolean
'Usage
Dim instance As MenuItem
Dim value As Boolean

value = instance.IsParent
public override bool IsParent { get; }
public:
virtual property bool IsParent {
    bool get () override;
}
/** @property */
public boolean get_IsParent ()
public override function get IsParent () : boolean

Eigenschaftenwert

true, wenn das Menüelement untergeordnete Menüelemente enthält. false, wenn das Menü ein eigenständiges Menüelement ist.

Hinweise

Mithilfe dieser Eigenschaft und der Parent-Eigenschaft können Sie in Code durch eine gesamte Menüstruktur navigieren.

Beispiel

Im folgenden Codebeispiel wird ermittelt, ob einem MenuItem mit dem Namen menuItem1 Untermenüs zugeordnet sind. Wenn Untermenüs vorhanden sind, werden diese durch Festlegen der Enabled-Eigenschaft auf false deaktiviert. Bei diesem Beispiel ist es erforderlich, dass ein MenuItem mit dem Namen menuItem1 erstellt wird.

Public Sub DisableMyChildMenus()
    ' Determine if menuItem2 is a parent menu.
    If menuItem2.IsParent = True Then
        ' Loop through all the submenus.
        Dim i As Integer
        For i = 0 To menuItem2.MenuItems.Count - 1
            ' Disable all of the submenus of menuItem2.
            menuItem2.MenuItems(i).Enabled = False
        Next i
    End If
End Sub
public void DisableMyChildMenus ()
{
   // Determine if menuItem2 is a parent menu.
   if(menuItem2.IsParent == true)
   {
      // Loop through all the submenus.
      for(int i = 0; i < menuItem2.MenuItems.Count; i++)
      {
         // Disable all of the submenus of menuItem2.
         menuItem2.MenuItems[i].Enabled = false;
      }
   }
}
void DisableMyChildMenus()
{
   
   // Determine if menuItem2 is a parent menu.
   if ( menuItem2->IsParent == true )
   {
      
      // Loop through all the submenus.
      for ( int i = 0; i < menuItem2->MenuItems->Count; i++ )
      {
         
         // Disable all of the submenus of menuItem2.
         menuItem2->MenuItems[ i ]->Enabled = false;

      }
   }
}
public void DisableMyChildMenus()
{
    // Determine if menuItem2 is a parent menu.
    if (menuItem2.get_IsParent() == true) {

        // Loop through all the submenus.
        for (int i = 0; i < menuItem2.get_MenuItems().get_Count(); i++) {

            // Disable all of the submenus of menuItem2.
            menuItem2.get_MenuItems().get_Item(i).set_Enabled(false);
        }
    }
} //DisableMyChildMenus

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MenuItem-Klasse
MenuItem-Member
System.Windows.Forms-Namespace