OK, once again... I hop you'll get it now :
Add a
ToolStrip
to your MDI Parent window. Add a button to the toolstrip and name it (for example)
toolButtonNew
. Set the
Text
property of
toolButtonNew
to
New.
Now create a new form (which will be your MDI Child form and add a
ToolStrip
to the child form. Add a button to the toolstrip and name it (for example)
mdiChildToolNew
. Set the
Text
property of the
mdiChildToolNew
to
New (this must be the same as the Text property value of the tool button on the MDI Parent). Now
this is important set the
MergeAction
property to
Replace
.
Now go back to your MDI Parent form, and add an event handler for the
MdiChildActivate
event and add the follwoing code :
private void Main_MdiChildActivate(object sender, EventArgs e)
{
ToolStripManager.RevertMerge(toolMain);
MdiChildForm frmChild = ActiveMdiChild as MdiChildForm;
if (frmChild != null)
{
ToolStripManager.Merge(frmChild.FormToolStrip, toolMain);
}
}
The result is that your MDI Parent
always contains a
new button, which will fire on the MDI Parent. Now if you open the MDI Child form (as MDI Child of the MDI Parent), the code above will replace the button on the
ToolStrip
of your MDI Parent and then the event will fire on the MDI Child. If you wish to
add a button from the MDI Child to the MDI Parent toolstrip, set the
MergeAction
property to the desired value (for example
Insert
).
I hop you'll get it now!
Eduard