I have a number of forms with almost identical menus. I want to create a Main Menu that has the common items on it, and then copy and paste the control to other forms. How can I implement it?
Here's where the power of OOP (Object-oriented programming) comes in.
You can create a "template" form that contains the MainMenu with the common MenuItems. Set the scope of the MainMenu control (Modifiers property) to public; this allows you to modify it on the other forms.
Then have the other forms inherit that form. To do that, change the line:
VB.NET:
Inherits System.Windows.Forms.Form
to
VB.NET:
Inherits RootNamespace.TemplateFormName
The power of this method is that if you need to make a change to all the menus, you only need to change the template form then rebuild and all the inherited forms will be changes as well.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.