MainMenu Constructor (array<MenuItem^>^)
.NET Framework (current version)
Namespace:
System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Return to top
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The following code example creates a MainMenu, and assigns two MenuItem objects to the MainMenu using this version of the constructor. The example then binds the MainMenu to a Form. This example requires that you have a Form created that is named Form1.
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^>^temp2 = {menuItem1,menuItem2}; MainMenu^ mainMenu1 = gcnew MainMenu( temp2 ); // Bind the MainMenu to Form1. Menu = mainMenu1; }
.NET Framework
Available since 1.1
Available since 1.1
Show: