SpeakComputers.com
Home
Software
Electronics
Desktop Computers
Laptops
Games
Handheld Devices
Mobile Phones
Cameras
Camcorders
Printers
Books
Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010
ASP.NET C# VB.NET C++ .NET Infragistics DevComponents

C++ MenuStrip Control.

The C++ Windows MenuStrip control provides an application menu system. The menustrip works with both Single document interfaces SDI and Multiple document interfaces MDI. With MDI applications the MenuStrip can be configured to merge with the main form for better navigation.

Namespace: System::Windows::Forms
System.Windows.Forms (in system.windows.forms.dll)

Creating an new C++ Windows forms MenuStrip.
MenuStrip^ menustrip = gcnew MenuStrip;

Assigning a new location for the C++ Windows Forms MenuStrip.
menustrip->Location = Point(0,0);

Assigning a size value to the C++ MenuStrip.
menustrip->Size = System::Drawing::Size(this->Width, 24);

Now we need to add menuitems to the menustrip control. The items I am speaking about are the dropdown menus, File, Edit, Windows etc, and the clickable button items within the menus, Open, Save, SaveAS etc.

Adding the first menu item - MenuStripItem.
ToolStripMenuItem^ menuitem1 = gcnew ToolStripMenuItem;

Assigning a text value to the MenuStripItem
menuitem1->Text = "File";

Adding an image to the MenuStripItem.
menuitem1->Image = Image::FromFile("E:\\file.png");

Now we add the first MenuStripItem to the MenuStrip itself.
menustrip->Items->Add(menuitem1);

Next we are going to add a second MenuStripItem but we are going to add it to the first MenuStripItem as a dropdown item.
ToolStripMenuItem^ menuitem2 = gcnew ToolStripMenuItem;
menuitem2->Text = "Exit";

Adding menuitem2 as a DropDown Menu item.
menuitem1->DropDownItems->Add(menuitem2);

Adding a C++ MenuStrip control to the form.
this->Controls->Add(menustrip);

Assign the MainMenuStrip to the form.
this->MainMenuStrip = menustrip;

Creating a Click Event for the C++ MenuStripItem control.
menuitem2->Click += gcnew System::EventHandler(this, &Form1::menuitem2_Click);

Responding to the C++ MenuStripItem Click event.
private: Void menuitem2_Click( Object^ sender, System::EventArgs^ e )
{
MessageBox::Show("Menuitem Clicked");
}

C++ MenuStrip control Tutorial.
Computer Security
AntiVirus Software
Internet Security
Parental Controls
Backup & Recovery
Computer Protection
Anti Malware
Photo & Video
Photo & Video Editing
Video Music
Desktop Publishing
Professional Design
Home Publishing
Clipart
Business & Accounting
Accounting
Payroll
Check Printing
TAX
H&R Block
Microsoft Office
Design
Graphic Design
Home Design
Garden Design
Interior Design
Computer Aided Design
3D Design
Students & Teacher
Adobe
Microsoft Office
Dragon Naturally Speaking
Corel Draw
Serif
Student/Teacher Software
Copy Right 2006 SpeakComputers.com - All Rights Reserved.
Home About Privacy Policy Resouces