How do I allow MDI Child Form A to know if MDI Child Form B is open in C#?

K

kstuver

Greetings:

I have an MDI application. I need for MDIChildFormA to be able to
determine if MDIChildFormB is open, so I can display a message to
finish edits in and close MDIChildFormB before I proceed with a delete
operation in MDIChildFormB.

How do I determine from MDIChildFormA if MDIChildFormB is open?

Thanks!!
Kent
 
M

Michael Höhne

Hi Kent,
you can use the MdiParent property of MDIChildFormA to get the MDI
container, which holds a list of all currently opened windows in its
MdiChildren property, so something like

foreach(Form mdiChildForm in this.MdiParent.MdiChildren) {
if (mdiChildForm == MDIChildFormB) {
//do your processing here
}
}

Of course, you cannot use the above comparison because you will likely not
have a reference to it, but I'm sure you'll find some properties that
uniquely identify the form in question.

Michael
 

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