Link to home
Start Free TrialLog in
Avatar of cycledude
cycledudeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

C#2010 winforms referencing the mdi parent form from a class

Hi

I have an application in which there is an mdiparent and lost of child forms.

I am trying to get a custom message form to appear in the parent from a class.. just to say 'please wait for process to complete'

so I created the form, and a reference to it:

form msg = new frmMessages()

now i need to tell the form that the mdiform is the parent, then display it .... this is where I am stuck
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

You should set this property when you create the child form:
childForm.MdiParent = this;
so the this.MdiParent in your child should give you what you want
Avatar of cycledude

ASKER

Hi

I am referencing the forms from a class, so 'this' is referencing the class and not the mdiform.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
top man ;o)
You could also check the IsMdiContainer() property:
            foreach(Form frm in Application.OpenForms)
            {
                if (frm.IsMdiContainer)
                {
                    Form msg = new frmMessages();
                    msg.MdiParent = frm;
                    break;
                }
            }

Open in new window