MenuItem.IsParent Własność
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Pobiera wartość wskazującą, czy element menu zawiera elementy menu podrzędnego.
public:
virtual property bool IsParent { bool get(); };
[System.ComponentModel.Browsable(false)]
public override bool IsParent { get; }
[<System.ComponentModel.Browsable(false)>]
member this.IsParent : bool
Public Overrides ReadOnly Property IsParent As Boolean
Wartość nieruchomości
true jeśli element menu zawiera elementy menu podrzędnego; false jeśli menu jest autonomicznym elementem menu.
- Atrybuty
Przykłady
Poniższy przykład kodu określa, czy istnieją jakieś podmenu skojarzone z nazwanym MenuItemmenuItem1. Jeśli istnieją jakiekolwiek podmenu, wyłącza je, ustawiając Enabled właściwość na false. Przykład wymaga utworzenia MenuItem pliku o nazwie menuItem1.
void DisableMyChildMenus()
{
// Determine if menuItem2 is a parent menu.
if ( menuItem2->IsParent)
{
// 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.IsParent)
{
// 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 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
Uwagi
Tej właściwości można użyć z właściwością Parent , aby nawigować w kodzie za pośrednictwem całej struktury menu.