Can I display a mainMenu in a Mdi Form?

  • Thread starter Thread starter Duncan Harris
  • Start date Start date
D

Duncan Harris

Hi,
I would like to display a MainMenu on a Mdi Form
but I can't get this to work. See my code example.
I think it should work since the SDK documentation doesn't seem to say
otherwise. I am using SDK 1.1.
Any help would be much appreciated.
cheers,
duncan
PS: This is driving me bananas!
using System;

using System.Windows.Forms;

using System.Drawing;

public class TestForm : Form {

public static void Main() {

TestForm f = new TestForm();

f.AddMdiChild();

Application.Run(f);

}

public TestForm() {

Text = "Parent Form";

ClientSize = new Size(400, 300);

IsMdiContainer = true;

// Create MainMenu for parent form.

Menu = new MainMenu();

MenuItem mi = new MenuItem("ParentMenu");

Menu.MenuItems.Add(mi);

MenuItem submi = new MenuItem("Exit");

mi.MenuItems.Add(submi);

}

private void AddMdiChild() {

Form f = new Form();

f.Text = "Child Form";

f.MdiParent = this;

// Create MainMenu for child form.

f.Menu = new MainMenu();

MenuItem mi = new MenuItem("ChildMenu");

f.Menu.MenuItems.Add(mi);

MenuItem submi = new MenuItem("Exit");

mi.MenuItems.Add(submi);

f.Show();

}

}
 
Menus created in MDI Child forms will be automatically moved to the main
form so that when activated, the child forms specialized menu items are
available.

Ensure that your menu items have the correct merge type and merge order.

--
Bob Powell [MVP]
C#, System.Drawing

Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm


ANNOUNCING: Well Formed.
The monthy electronic magazine for
Windows Forms and GDI+ engineers
http://www.bobpowell.net/wellformed.htm

*September issue now available*
 
Back
Top