Help: Questions regarding Modal forms

G

Guest

I have some questions regarding Modal forms and would appreciate if someone
could clarify my understanding.

(a) I observed that the modal form's Form_Closing event is generated if I
set the modal form's Visible property to False or call its Hide method. Is
this true? or is it a result of something that I am doing incorrectly?

(b) The ShowDialog method halts all other execution in a single threaded
program till the modal form is closed, right?

(c) I noticed that if I Hide the modal form or set its Visible property to
False, then the ShowDialog method returns. Is this correct behaviour? Is
there a way to avoid this?

TIA.
 
R

Richard Myers

(a) I observed that the modal form's Form_Closing event is generated if I
set the modal form's Visible property to False or call its Hide method. Is
this true? or is it a result of something that I am doing incorrectly?

Yes it true.
(b) The ShowDialog method halts all other execution in a single threaded
program till the modal form is closed, right?

Yes with the exception of whatever is running in the modal form itself.
(c) I noticed that if I Hide the modal form or set its Visible property to
False, then the ShowDialog method returns. Is this correct behaviour? Is
there a way to avoid this?

Yes it is. Dont show the form using showDialog. Use form.Show().

Richard
 
G

Guest

Hi Richard,

Thanks for your response.

I am using ShowDialog because I want the form to be displayed as a Modal
form. This form opens up another form and you can switch back and forth
between the 2 forms. Once both these forms are closed then I need to do some
processing on the main form, like adding an item to the TreeView of the main
form.

Do you have any sugesstions for the same? Currently what is happening is
that on Hide the Modal form returns and the main form processing takes place
too early.

TIA.
 
G

Guest

I think I found a solution to my problem.

Use ShowDialog for the 1st form. Show the 2nd form as an owned form. I made
the size and thelocations of the 2 forms equal, so although the form is an
owned form, it appears as if the 1st form has been hidden and only the 2nd
form is being displayed.
 

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

Similar Threads

Modal Forms 2
How to make MODAL MDIChild 8
Modal property 7
Modal Forms 3
Testing for Modal form 4
Strange modal form behaviour 1
Non-modal form doesn't close 2
Problems when canceling OnClosing 12

Top