MDI Forms using MainMenu

J

jp2msft

Whenever I launch an MDI Child, I can add items to the MDI Parent's MainMenu
easy enough, but how do I call them from the MDI Child?

In the Parent,

private void miPrint_Click(object sender, EventArgs e) { /* code */ }

What changes? The Menu Item miPrint is still located in the Parent. Do I
need to check the sender object?

Whenever text is selected in my MDI Child, how do I tell the MDI Parent's
MainMenu to activate the Cut/Copy menu items?

If I click "Select All" in the MainMenu, how do I tell the active MDI Child
to respond to this?

MDI Forms are new to me, and they don't seem to be covered in many books.
 
Z

zacks

Whenever I launch an MDI Child, I can add items to the MDI Parent's MainMenu
easy enough, but how do I call them from the MDI Child?

In the Parent,

private void miPrint_Click(object sender, EventArgs e) { /* code */ }

What changes? The Menu Item miPrint is still located in the Parent. Do I
need to check the sender object?

Whenever text is selected in my MDI Child, how do I tell the MDI Parent's
MainMenu to activate the Cut/Copy menu items?

If I click "Select All" in the MainMenu, how do I tell the active MDI Child
to respond to this?

MDI Forms are new to me, and they don't seem to be covered in many books.

You'll need to setup a line of communications between them.

When a main form menu is invoked that is designed to do something in a
child window, then you will need a public method in the child form's
code to act as a "delegate". In the menu item's click event you will
invoke that public method in the active child form (there is a
property for the current active child, you will need to cast it to the
actual child form in order to get the publiuc method to show up in
intellisense).

SImilarly, to enable a main form menu item from a child form, the main
form needs a public method that will do that, and invoke that method
from the child form's code using the MDIParent property. Again, to see
that method in intellisense you will need to cast the MDIParent
property to the main form's form name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top