It's a bit weird stuff: there is no such concept as "open" form. You can only check if it is
(there is such Boolean property) or not. I'm not sure you need to check it though. Please keep reading.
You create a form (with a constructor), show it and then close. If the form is closed (not hidden, which is most usually done with non-main forms through interception of "close by the user" event by handling
, cancellation the event and hiding), but really closed, it gets disposed, so then you cannot open it again
, but can read its properties.
So, you could also handle the event
, let it be closed and set some flag in it which you can test later.
I don't think this is what you really need. You don't really need to know the status of the form. You just need to use appropriate pattern of its usage.
If you use a form using only
, you should not call
. Just remove the line with the call to
Close; and it will work just fine.
This way, you can simply call
any number of times. This is the best way of showing a form in a modal way, because if will keep its status.
If you want to show form as non-modal using
, or you need to mix it with
(by some weird reason), the best pattern is cancellation of
(the event argument parameter has the member
you should assign to true if closing reason is
. Please see:
Alternatively (and even better, because your form class subclasses
anyway), override the virtual method