NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MenuItem.Parent

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;

Property Value

A Menu that represents the menu that contains this menu item.

Remarks

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.

Example [Visual Basic]

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

See Also

MenuItem Class | MenuItem Members | System.WinForms Namespace