Merge MDI Toolbar - Parent

I found information on the Internet, but nothing helped me. How to combine toolbar in parent mdi form?

Edit:

This worked for me with this code:

private void MainForm_MdiChildActivate(object sender, EventArgs e) { IChildWindow child = ActiveMdiChild as IChildWindow; if (child != null) { ToolStripManager.Merge(child.ToolStrip, toolStrip1); child.ToolStrip.Hide(); child.FormClosing += delegate(object sender2, FormClosingEventArgs fe) { child.ToolStrip.Show(); ToolStripManager.RevertMerge(toolStrip1, child.ToolStrip); }; } } 
+4
source share
2 answers

You need to use ToolStripManager . It has a method called Merge(ToolStrip, ToolStrip) that does what you want. Look here

For instance:

 ToolStripManager.Merge(((YourChildForm)this.ActiveMdiChild).ToolStrip, parentFormToolStrip); 
+6
source

Inside a child form, you can also do the following:

 Private Sub Child_ParentChanged(sender As Object, e As System.EventArgs) Handles Me.ParentChanged Try ToolStripManager.Merge(Me.ToolStrip, TryCast(sender.mdiParent, frmMain).ToolStrip) Catch ex As Exception mErrorLog.ApplicationErrorLog(Me.GetType.Name, "frmTechSelectWO_ParentChanged", ex.ToString) Finally Me.ToolStrip.Hide() Me.MenuStrip1.Hide() End Try End Sub Private Sub Child_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing ' ' Clean up the parent toolbar Try ToolStripManager.RevertMerge(TryCast(Me.MdiParent, frmMain).ToolStrip) Catch ex As Exception End Try End Sub 
0
source

Source: https://habr.com/ru/post/1343069/


All Articles