[英]Merge toolstrip MDI child - parent
I found some informations on the internet but nothing helped me out. 我在互联网上找到了一些信息,但没有任何帮助我。 How can I merge a toolstrip in the parent mdi form?
如何合并父mdi表单中的工具条?
Edit: 编辑:
It 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);
};
}
}
You need to use a ToolStripManager
. 您需要使用
ToolStripManager
。 It has a method called Merge(ToolStrip, ToolStrip)
which does what you want to. 它有一个名为
Merge(ToolStrip, ToolStrip)
的方法Merge(ToolStrip, ToolStrip)
您的需求。 See here 看这里
For example: 例如:
ToolStripManager.Merge(((YourChildForm)this.ActiveMdiChild).ToolStrip, parentFormToolStrip);
From within the child form one can also perform 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.