Search code examples
c#winformsmdichild

WinForms MDI Child Forms


I have a form frmMain set up as MDI Parent. Within that I can open another form frmSearch as a child form inside the Parent. However, what I am having an issue with, is I now want the user to be able to open a third form frmCase, from a click on frmSearch, and have this third window also open inside the Parent form frmMain.

So far I have on frmMain:

Form fS = new frmSearch();
fS.MdiParent = this;
fS.Show();

And on the child form frmSearch:

frmCase fC = new frmCase(strCaseNo);
fC.Show();

But the third form (frmCase) opens up outside of the parent form (frmMain) I know I need to set the MDIParent property of frmCase but I don't know how to reference the already open frmMain.

Any advice would be appreciated.


Solution

  • This was the answer: fC.MdiParent=this.MdiParent