Merging menus in MDI forms

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
15,033
Location
Sydney, Australia
Programming Experience
10+
Judging by Office 2003, Microsoft have decided that the "proper" way to deal with menus and toolbars in MDI forms is to show everything in the parent. When Word, etc. is set to not display document icons in the taskbar, you can layout your child windows in the "old" fashion, but all menu and toolbar items are displayed in the parent window. Personally, I like the way many, if not all, applications used to do things, where menu and toolbar items are displayed in the child window unless the child is maximised. I tried to implement this recently and found it impossible to switch from one mode to the other. I must admit, I knew things were going to change markedly in .NET 2.0 so I didn't try too hard. I've been playing with beta 2 of VB.NET Express and found that while things were different, I still couldn't find an easy way to change from one mode to the other. The MenuStrip class inherits the AllowMerge property from the ToolStrip class, which causes menus to behave correctly at startup, but changing the value of the property mid-stream seems to have no effect.

My question is this:

Does anyone know a simple way to merge and unmerge MainMenu (.NET 1.1) objects and/or MenuStrip (.NET 2.0) objects on demand?
 
Is it posible that the mainmenu from the child not merge with the parent mainmenu.
so that the child has his own menu in his own form ?
 
jmcilhinney:
This code called in mdichild will unmerge it's menustrip1 from mdiparents menustrip.
VB.NET:
[/SIZE]
[SIZE=2]ToolStripManager.RevertMerge([SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].MdiParent.Controls([/SIZE][SIZE=2][COLOR=#800000]"MenuStrip"[/COLOR][/SIZE][SIZE=2]), MenuStrip1)
[/SIZE]
ToolStripManager class is new in .Net 2.0, it got both merge/revertmerge methods etc to play with.

Heppen:
Just set AllowMerge=False for the menu you don't want to merge automatically.

 
Thanks JohnH. I wasn't aware of the ToolStripManager class. As you can see, this is a relatively old thread and I was using primarily .NET 1.1 at the time. I'm about to migrate the majority of my work to 2.0 so I'll investigate that class.
 
Back
Top