Menu::IsParent Property
.NET Framework (current version)
Gets a value indicating whether this menu contains any menu items. This property is read-only.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [BrowsableAttribute(false)] property bool IsParent { [SecurityPermissionAttribute(SecurityAction::InheritanceDemand, Flags = SecurityPermissionFlag::UnmanagedCode)] virtual bool get(); }
Property Value
Type: System::Booleantrue if this menu contains MenuItem objects; otherwise, false. The default is false.
The following code example creates a MainMenu with two MenuItem objects. It then uses the IsParent property to determine whether mainMenu1 contains menu items. If the condition evaluates true, it sets the RightToLeft property to true and binds the main menu to the Form. This example requires that you have a Form created that is named Form1.
public: void CreateMyMainMenu() { // Create two MenuItem objects and assign to array. MenuItem^ menuItem1 = gcnew MenuItem; MenuItem^ menuItem2 = gcnew MenuItem; menuItem1->Text = "&File"; menuItem2->Text = "&Edit"; // Create a MainMenu and assign MenuItem objects. array<MenuItem^>^menuMenu1Items = {menuItem1,menuItem2}; MainMenu^ mainMenu1 = gcnew MainMenu( menuMenu1Items ); // Determine whether mainMenu1 contains menu items. if ( mainMenu1->IsParent ) { // Set the RightToLeft property for mainMenu1. mainMenu1->RightToLeft = ::RightToLeft::Yes; // Bind the MainMenu to Form1. Menu = mainMenu1; } }
SecurityPermission
for operating with unmanaged code. Associated enumeration: UnmanagedCode
.NET Framework
Available since 1.1
Available since 1.1
Show: