C# – How to have multiple forms share a common menu in a Winforms app

cmenunetwinforms

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!

Best Answer

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
Related Topic