0

How to have a child form menu replace the parent form in an mdi app (not just merge with it)? My question is similar to this but there are times when the parent menu needs to show up when no child forms are shown and other situations so I can't have the parent menu be empty all the time.

The child form menustrip's AllowMerge is set to true. My idea is that when the user selects the menu option to show a child form, the child form's menustrip would merge with the parent's empty menu giving the appearance of child menu replacing the parent menu. The code below intention is to make that happen. However the result is that the menu is blank. The child's menu is not showing. I am guessing there's more to happen but I don't know the proper process.

Code in Main Form:

Control[] c = Controls.Find("menuStripMain", true);
Control savedMenu = c[0];
Controls.Remove(c[0]);                                        
MenuStrip n = new MenuStrip();
this.MainMenuStrip = n;
ChildForm cw = new ChildForm();
sw.MdiParent = this;
sw.Show();
sw.Focus();
Community
  • 1
  • 1
Tony_Henrich
  • 42,411
  • 75
  • 239
  • 374

0 Answers0