MDIChild form

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
 
?

=?ISO-8859-2?Q?Marcin_Grz=EAbski?=

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top