fj fj

fj fj

  • NA
  • 6
  • 0

Menu on another form

Oct 28 2005 8:32 AM

Hi there.
I ran into some difficulties and I hope someone here can help me.
I created a form (f1) and put a button on it. When the button is pressed I want another form (f2) to pop up with a menu on it. I have been unable to figure out how to put the menu on the f2 form. Here is what I did:

private void button2_Click (object sender, EventArgs ea)

{

Form f2 = new Form();

f2.Show();

f2.BackColor = Color.White;

Label palli = new Label();

palli.Text ="Palli var einn";

palli.Location = new Point (40, 110);

f2.Controls.Add(palli);

MainMenu MyMenu = new MainMenu();

MenuItem m1 = new MenuItem("File");

MyMenu.MenuItems.Add(m1);

MenuItem subm1 = new MenuItem("Hello");

m1.MenuItems.Add(subm1);

subm1.Click += new EventHandler(prentavalið);

Menu = MyMenu;

}
The problem with this solution is that it creates a menu on f1 when the button is pressed, not on f2 but that is what I want.
Can someone please help me?
Regards,


Answers (1)