Determine If A Child Form Has Been Closed?

G

Gary Brown

Hi,

I need to either determine that a child form has been closed or
disable the close box without removing the entire control box.

Is there an easy way to determine if a child form has been closed?
This is modeless, not MDI. I haven't found a already defined event
for this non-MDI case. The form instance still resides in the parent
form. Is there something in it that can be checked?

What I have is:

if (CRT == null)
{
CType30CRT Display = new CType30CRT();
CRT.Show(this);
}

Also, there does not appear to be a means to disable the close box
in the child window. It can be programmed to be ignored but that
leaves an enabled close box to confuse the user.

There are workarounds but I would prefer something less clumsy.

Thanks,
Gary
 
P

Peter Duniho

[...]
Is there an easy way to determine if a child form has been closed?
This is modeless, not MDI. I haven't found a already defined event
for this non-MDI case.

Every form has a FormClosed event, MDI or not. You should be able to
subscribe to that event to receive notification that the form has been
closed.

As far as disabling the close box goes, I'm not aware of any built-in way
to do that. I think you could probably override the window class and draw
your own close box, but that's not really a .NET-friendly way to do it.
Maybe if you can explain why simply removing the control box altogether
isn't a good solution for you, someone can offer a suggestion that does
work better within the .NET paradigm.

Pete
 
E

Egghead

may be you should put the child form into singleton pattern, then null the
form after it closed
 

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