Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a main form in Visual Studio C# which has the IsMdiContainer set to True.
I tried to open a child form using
frm_edit_s = new frm_edit_sensor();
frm_edit_s.FLG_parent_form = this;
frm_edit_s.MdiParent = this;
frm_edit_s.FormClosed += new FormClosedEventHandler(frm_video_closed);
frm_edit_s.BringToFront();
frm_edit_s.Visible = true;
frm_edit_s.Show();

When the code is executed, I can step through the code but the child form is not displayed. It seems to be there as the FormClosed event fires when the program is stopped.
If I remove the
frm_edit_s.MdiParent = this;
line, the form is displayed
On searching , it seems to be related to MenuStrip which is used in the parent form though I cannot find a solution. Any advice appreciated
Regards

What I have tried:

I have tried launching the child from from a button rather than from the menustrip
as well as making sure the form is visible and at the front
Posted
Updated 14-May-21 3:57am

1 solution

See the note here: Form.MdiParent Property (System.Windows.Forms) | Microsoft Docs[^]
Quote:
If there are two MenuStrip controls on an MDI child form, setting IsMdiContainer to true for the parent form merges the contents of only one of the MenuStrip controls. Use Merge to merge the contents of additional child MenuStrip controls on the MDI parent form.

But in general: if you can avoid using MDI you should do that, otherwise things can get painful.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900