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();
}
}
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();
}
}