I do this every few months and can never remeber what is to be do for this to work. I always spend few minutes looking through code that does merging and sets apprioprate values in among other design-time settings… so here it is, for me to rember.
- Set MainMenu strip on Mdi parent box.
- Set visible false on Mdi child ToolStrip and MenuStrip
- Add this to Mdi parent box:
///<summary> ///Raises the <see cref="E:System.Windows.Forms.Form.MdiChildActivate"></see> event. ///</summary> /// ///<param name="e">The <see cref="T:System.EventArgs"></see> that contains the event data. </param> protected override void OnMdiChildActivate(EventArgs e) { base.OnMdiChildActivate(e); MergeChildToolStrip(); } /// <summary> /// Merges child window ToolStrips /// </summary> private void MergeChildToolStrip() { ToolStripManager.RevertMerge(mainToolStrip); IChildBox box = ActiveMdiChild as IChildBox; if (box != null) { ToolStripManager.Merge(box.ToolStrip, mainToolStrip); } }
- Create IChildBox interface and implement it on Mdi child box.