I have main form and some other forms, that can be shown by controls, placed on the main form, using ShowDialog(control). Also I have event handler on the main form, that can be handled anytime. How can I check inside it, is there any other dialog forms?
A:
If I understand you correctly, you're asking if inside your main form's event handler, you can check to see if any other forms are open.
If you show these forms using ShowDialog
then your main form's thread is blocked until that new form is closed. I believe any events fired during that time will wait, and be handled after the form closes.
If you show these forms using Show
then you need to keep some reference to the form in order to check on them during your event handler.
If you word your question a little clearer, maybe I can help more.
Daniel Rasmussen
2010-05-21 04:43:20
Sorry, I have some troubles with English.My event handler handles event from another static class (my application is multithreaded and I'm using this static class as shared memory). So it can be called anytime just like simple method. Or may be I am wrong?
dimanyuk
2010-05-21 04:54:07
If you're multithreading, then I believe it's possible, as you described. Like Ram said, you can use `form.visible`. Make sure you have proper thread-safe precautions in place, tho, and be sure to save your instance of the form somewhere you can access it in your handler. That is, if you just call `(new MyDialog()).ShowDialog()` you'll have no way to check it's visibility later.
Daniel Rasmussen
2010-05-21 17:09:43
A:
You might want to have a look at the Application.OpenForms. You can have a look in the collection.
PieterG
2010-05-21 05:30:58