MDIChild form

  • Thread starter Thread starter Adi
  • Start date Start date
A

Adi

Hi
I got problem with Mdi form, I would like to check if child form is already
created and opened
(I have a few child forms).
And if it is open to make it focus else create new instance of the form. How
can I do this?
Please help me,
How can I check if MyMDIForm is alerady created when i execute this code
again
private void Button_Click(object sender, System.EventArgs e)

{

FmForm2 MyMDIForm = new FmForm2();

MyMDIForm.MdiParent = this;

MyMDIForm.Show();

}
Regards
Adam
 
Hi Adam,

There is "Form.MdiChildren" property that returns Form[].

If you want to check if your "MyMDIForm" is one of the
MdiChildren then you can iterate through them e.g.:

Form[] mdiChildren=this.MdiChildren;
for(int i=0; i<mdiChildren.Length; i++) {
if( mdiChildren is MyMDIForm ) {
// i-child is instance of MyMDIForm :-)
mdiChildren.Activate(); // for instance
}
}

Cheers!

Marcin
 
Back
Top