Gets the menu in which this menu item appears.
[Visual Basic] Public ReadOnly Property Parent As Menu [C#] public Menu Parent {get;} [C++] public: __property Menu* get_Parent(); [JScript] public function get Parent() : Menu;
A Menu that represents the menu that contains this menu item.
You can use this property to obtain the Menu object for a submenu. You can cast the Menu object returned by this property to a MenuItem object to manipulate it.
The following example changes a submenu item's parent menu item using Parent property. The example assumes that there are two menu Items called MenuItem1 and MenuItem2. MenuItem2 is a sub menu of MenuItem1. The example uses the DefaultItem property to make MenuItem1, the parent menu item, the default menu item.
[Visual Basic]
Public Sub ChangeMyParentMenu() ' Create a temporary menu. Dim tempMenu as MenuItem ' Obtain the parent menu item of MenuItem2 (MenuItem1). Set tempMenu = (MenuItem) MenuItem2.Parent ' Set the default property to true to make MenuItem1 the default menu item in its menu. tempMenu.DefaultItem = True End Sub
MenuItem Class | MenuItem Members | System.WinForms Namespace