views:

94

answers:

2

I have an existing .NET Winforms app made with a few complex forms, and

1) the forms all live for the life of the app, and

2) only one form is displayed at a time (the user switches between the forms)

I need for these forms to share a common menu that will be processed by a single business-logic controller. (The visible form is also continuously updated by the controller)

Is there a way to the same menu appear at the top of each form and have the menu processed by their common controller without having to make it an MDI application?

Many thanks!

A: 

Build the menu in a custom control (user control), and then add that control to each of your forms.

md5sum
+1  A: 

Create a base form with the menu. Then the individual forms can inherit this base form, automatically getting the same menu. To refactor the existing forms, edit the form.cs and change

 public partial class Form1 : Form 

to

 public partial class Form1 : MyBaseForm
Hans Passant
I would also add your menu commands as private methods that call a virtual or abstract On<MenuItemName> function so you can handle the actions differently on each form. For common actions you should be able to code them into your base form directly.
Joshua Cauble