Can child forms listen for events on the parents mainmenu?

S

Sean Connery

I know I can merge a child forms menu into the MDI parent's mainmenu, but I
would also like to listen for common events fired from the mainmenu that
might be of interest to any child forms.

Is this possible?
 
N

Nicholas Paldino [.NET/C# MVP]

Sean,

In order to do this, you will have to do some coding yourself.
Basically, you will have to register "listeners" with the parent form which
will be called when the menu items are clicked. When this happens, the
parent form will have to cycle through the listeners, seeing which one
handles the menu item that was clicked.

How you do this is up to you, as there are a number of ways that this
could be designed, but the overall concept is that the child forms would
register with the parent through some general mechanism indicating when a
menu item is clicked.

Hope this helps.
 
S

Sean Connery

I was afraid it wasn't going to be simple. Do you know of any code samples
where this is done?
 
N

Nicholas Paldino [.NET/C# MVP]

Sean,

I don't know of any offhand. There might be something at
codeproject.com. You want to find something that implements a Command
pattern, as this is really what you are trying to do (a Command
infrastructure actually gives you a little more, but at its core, it's what
you want).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Sean Connery said:
I was afraid it wasn't going to be simple. Do you know of any code samples
where this is done?

message news:[email protected]...
 
S

Sunil

Hi,

I have MDI Child and MDI Parent Window. Now I have FILE and EDIT menu
in Parent as well as Child window. When my Child window is launched,
the FILE menu of child should get merged to FILE menu of Parent and
EDIT menu of Child should get merged to EDIT menu of Parent. Can you
tell me how to do this? Also can you tell me how to trigger the click
events of CHILD MENU.

Thanks in advance.

Regards,
Sunil
 

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