By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

Hidden modal form is not included in My.Application.OpenForms

P: n/a
I am trying to close/dispose multiple instances of a form but because they
are modal and hidden, they do not show up in My.Application.OpenForms. They
must be modal, so making them modeless is not an option. I also need to
check the values in a spread control on the forms before I close/dispose
them. I'm using VB 2005. Is there some way for me to do this?
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"ginacresse" <gi********@discussions.microsoft.comschrieb
I am trying to close/dispose multiple instances of a form but
because they are modal and hidden, they do not show up in
My.Application.OpenForms.
Hidden Forms can not be modal. If you hide them, ShowDialog returns.
Consequently they are not in a modal state anymore.

They must be modal, so making them
modeless is not an option. I also need to check the values in a
spread control on the forms before I close/dispose them.
Close and Dispose are different things with modal Forms. You can close
the Form, then access the spread control on the Form, then Dispose the
Form.
Only with modeless Forms, closing also means disposing. Just for the
purpose you mentioned that's different with modal Forms.
I'm using
VB 2005. Is there some way for me to do this?
Other than accessing the spread control?

Is there a reason why you mentioned My.Application.OpenForms? If you
have shown several instances of a modal Form, there must be one on top
of the other. Otherwise you'd have to create multiple UI threads.
However, if they are all hidden, there must be any Form left over,
right? Could you please give a picture of your UI infrastructure (which
Form shows which one, and how (modal/modeless)? MDI Form available?
Project's startup object is a Form? Are there owner-child relations)?
Armin

Jun 27 '08 #2

P: n/a
I hope this doesn't get posted twice, but I tried to reply once and it never
showed up.
The forms are structured as follows:
The startup form is an MDI form. The user can Show a child form (Form1)
from the MDI form. Form1 has a context menu item that, when clicked, creates
a new instance of Form2 with ShowDialog() (I assume this means Form2 is
Modal, which is why I use the term). Form2 has Button1 and Button2. If the
user clicks Button1, a new instance of Form3 is created and shown with
ShowDialog(). When the user is done with Form3, it gets hidden with
me.hide(). The user can keep coming back to Form3 (generated with Button1)
and the data on the form will still be there. The user can also click
Button2 and create another instance of Form3 (specifically created with
Button2) and ShowDialog(), then hide it when done. There may be other
instances of Form3 open/hidden in the application, but when the user closes
Form2, I want to Dispose the instances of Form3 that were created with
Button1 and Button2. The reason I wanted to be able to check the spread
control on Form3 was to somehow determine if it is a form I want to dispose,
but there is probably a better way. I’ve been reading about OwnedForms and
maybe that is the route I should take? Anyhow, any help is appreciated.
Thanks.

Jun 27 '08 #3

P: n/a
Thx for the detailled description. I'll have a look when I'm awake (the
real being awake).

AZ

Jun 27 '08 #4

P: n/a
I ended up solving the problem another way. When I create each new instance
of Form3, I add it to the list of OwnedForms for Form2. When I close Form2,
I loop through Form2.OwnedForms and dispose them. Works great.

Thanks.

Gina
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.