I'm creating an application, where the main form that is shown when the application is started is a MDI container. I assigned a context menu to this form, so that the user can use this menu to open MDI children.
This works just fine, but when I right click in a MDI child, the context menu of the MDI container (main form) opens, even though the child form does not have any context menu assigned, so I would expect (and want) no menu to open on right click.
How do I make sure that the children does not show the parent context menu?
As a side note I am working in VS2005, but I don't think this is relevant here.
I just can't seem to find the option / property to change this, and I would expect the default behaviour was the forms only show a context menu if one is assigned to them.
Unfortunately, setting the child form's ContextMenuStrip to null only makes it show the MDI parent's ContextMenuStrip. The hack is to assign an empty ContextMenuStrip to the child form:
void button1_Click(object sender, EventArgs e) {
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.ContextMenuStrip = new ContextMenuStrip();
f2.Show();
}