MainMenu Constructor ()
.NET Framework (current version)
Initializes a new instance of the MainMenu class without any specified menu items.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The following code example creates a MainMenu, assigns two MenuItem objects to the MainMenu and binds it to a form. This example requires that you have a Form created that is named Form1.
void CreateMyMainMenu() { // Create an empty MainMenu. MainMenu^ mainMenu1 = gcnew MainMenu; MenuItem^ menuItem1 = gcnew MenuItem; MenuItem^ menuItem2 = gcnew MenuItem; menuItem1->Text = "File"; menuItem2->Text = "Edit"; // Add two MenuItem objects to the MainMenu. mainMenu1->MenuItems->Add( menuItem1 ); mainMenu1->MenuItems->Add( menuItem2 ); // Bind the MainMenu to Form1. Menu = mainMenu1; }
.NET Framework
Available since 1.1
Available since 1.1
Show: