Standard Windows menu bars in Windows Forms
Go to your Toolbox, right click anywhere inside and select "Choose Items".
When the dialog loads and appears, scroll down til you see MainMenu. Add that to the toolbox, and you've got yourself a native menu bar!
You can do this by setting your form's Menu
property, like this:
private void Form1_Load(object sender, EventArgs e){ this.Menu = new MainMenu(); MenuItem item = new MenuItem("File"); this.Menu.MenuItems.Add(item); item.MenuItems.Add("Save", new EventHandler(Save_Click)); item.MenuItems.Add("Open", new EventHandler(Open_Click)); item = new MenuItem("Edit"); this.Menu.MenuItems.Add(item); item.MenuItems.Add("Copy", new EventHandler(Copy_Click)); item.MenuItems.Add("Paste", new EventHandler(Paste_Click)); // etc ...}private void Save_Click(object sender, EventArgs e){ // save}
These menus will look like "normal" system menus.
I couldn't find any designer support for this, though. In my defense, I didn't try real hard.
Instead of using a the MainMenu
component you can create your own renderer for the MenuStrip
component. The advantage here is being able to add images to MenuStripItem
objects. Here is the pastebin for the custom renderer:
There are different themes that can be applied in the constructor of the renderer. Try them all to see the native themes. To use this renderer simply set the instance to the MenuStrip
Renderer property:
menuStrip.Renderer = new NativeRenderer([theme]);