Main Menu - common code?

  • Thread starter Thread starter Rob Meade
  • Start date Start date
R

Rob Meade

Hi all,

I am putting a small app together which will have 3 windows forms, the main
menu across the top will be the same regardless of which form the user is
on. I have noticed that as I built the first form it has added all of the
'protected with events' stuff for the main menu bits and bobs.

I'm thinking that I would be better of with my main menu code somewhere
seperate, just the once and then call it as needed for each form - any
changes are then only done the once...

Can someone suggest how I might do this please.

Any help appreciated (new to .net and windows stuff - mainly worked on the
web side of things with .net so far).

Regards

Rob
 
Consider creating a 'master form' that has the menu on it, along with all
the event-handling code, and then inheriting that form in your app's forms.
That way the menu and event-handling code comes along for free, and each
time you make a change to the master form and rebuild the forms that inherit
from it will get the changes as well.

One warning: you'll need to do a build after creating the master form,
before it's available to be inherited from in the VS.Net IDE.

Tom Dacon
Dacon Software Consulting
 
...
Consider creating a 'master form' that has the menu on it, along with all
the event-handling code, and then inheriting that form in your app's forms.
That way the menu and event-handling code comes along for free, and each
time you make a change to the master form and rebuild the forms that inherit
from it will get the changes as well.

Hi Tom,

Many thanks for your reply.

I have created a new form and taken the code from the original form for the
menu and added it to the master form. When I view the master form the menu
works corrected.

I have run a build on the solution - there are only 2 forms etc.

When I try to view the original form (within VS) which is now using:

Inherit MasterForm

I get 2 errors - they are both the same and read:

Cannot bind an event handler to the 'Click' event because it is read only.

I have tried double clicking these hoping that it might take me to the
erroring code, but no joy.

These weren't an issue prior to the 'inherits' bit etc, so I assume I need
to change some other stuff to.

As you can probably guess I'm not exactly a .net guru - literally just
finding my feet - so if you could offer any help on this one I'd be
grateful.

Regards

Rob
 
Hi Tom,

Please ignore the question in my last post regarding the 2 errors, I didn't
take out the functions that react to the onclick events to the menu
items..doh!...

Thanks again for your previous help.

Regards

Rob
 
Back
Top