Cloned menu

  • Thread starter Thread starter Dave Taylor
  • Start date Start date
D

Dave Taylor

I have two separate Windows forms, frmA and frmB, both are MDI child
windows. But frmB is also a "child" of frmA...at least conceptually
speaking. So I want both frmA and frmB to share the same menu, is it
possible to do this?

So far, I have tried setting frmB.Menu = frmA.Menu, but that didnt work very
well. And setting frmB.Menu = frmA.Menu.Clone works great except for the
menu objects are now two separate instances, so updating one menu does not
update the other.

Any other suggestions?

Thanks

Dave Taylor
 
Dave
I do not know of anyway for one forms menu to update another forms menu
automatically. You could probably do it programatically if you made the
other forms menu public, then you should be able to change what you want to.

Someone else may have a better solution.

HTH
Les
http://www.KnowDotNet.com
 
Les,

Thanks for the reply, I have worked it out by using keeping a reference to
the parent form's menu, and then using each form's Activate event, I set the
form.Menu to the member variable, so I have something similar to the
following which seems to work

Class frmA
Private _mnu As Menu
Private _child As frmB

frmA_Load()
_mnu = Me.Menu
End

frmA_Activate()
Me.Menu = _mnu
End

ShowChild()
_child = New frmB(Me)
End

SharedMenu() As Menu
Return _mnu
End
End Class

Class frmB
_parent As frmA

New(Parent As FrmA)
_parent = Parent
End

frmB_Activate()
Me.Menu = frmA.SharedMenu
End
End Class
 
Back
Top