Detecting when another form has closed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have a form called form1 and I load up a dialog form from it as shown below:
Dim Myform As Form
Myform = New frmOrderEntry()
Myform.Show()

I wish to run a procedure in this form called "RefreshGrid" once the frmOrderEntry form has been edited and closed.
How do I detect when the frmOrderEntry has been closed and make it wait for this to happen.

Thanx in advance

Robert
 
* "=?Utf-8?B?Um9iZXJ0IEJhdHQ=?= said:
I have a form called form1 and I load up a dialog form from it as shown below:
Dim Myform As Form
Myform = New frmOrderEntry()
Myform.Show()

I wish to run a procedure in this form called "RefreshGrid" once the frmOrderEntry form has been edited and closed.
How do I detect when the frmOrderEntry has been closed and make it wait for this to happen.

Call 'ShowDialog' instead of 'Show'.
 
Robert,
Myform.ShowDialog()

HTH
Les
http://www.KnowDotNet.com

Robert Batt said:
Hello,
I have a form called form1 and I load up a dialog form from it as shown below:
Dim Myform As Form
Myform = New frmOrderEntry()
Myform.Show()

I wish to run a procedure in this form called "RefreshGrid" once the
frmOrderEntry form has been edited and closed.
 
B. Chernick said:
Excuse me but I have a similar problem. I have coded:

dim x as newForm
x.ShowDialog()
' Do other stuff here'
The problem is that I cannot get anything to happen after the
ShowDialog. Any breakpoint I set after the ShowDialog is never
reached.

What am I doing wrong? (More importantly, what basic principle am I
not understanding?)

Maybe dumb question, but did you close Form x?


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
My apologies again. I have misstated the problem (or I have two separate problems)

First, yes, form x is always closed. However, I've been tweaking on my code, on the assumption that the particular point I was calling this form was the problem. Originally I was calling it from the MouseUp event of a data grid (in order to edit the selected record). Under that setup, there was no sign of any action after the ShowDialog call.

Now, I have moved all the form-related code to a separate subroutine, to be called by both the grid event and a button. Under this setup, the code keeps on going without delay after the ShowDialog call.
 
B. Chernick said:
My apologies again. I have misstated the problem (or I have two
separate problems).

First, yes, form x is always closed. However, I've been tweaking on
my code, on the assumption that the particular point I was calling
this form was the problem. Originally I was calling it from the
MouseUp event of a data grid (in order to edit the selected record).
Under that setup, there was no sign of any action after the
ShowDialog call.

Now, I have moved all the form-related code to a separate subroutine,
to be called by both the grid event and a button. Under this setup,
the code keeps on going without delay after the ShowDialog call.

Problem solved?
 
? No, either way I have a problem. How do I detect that the 2nd form has closed? All my reading so far about the ShowDialog method seems to say that I should expect the application to come back to the original code ONLY after the 2nd form has closed but in every example I've run, it keeps on running. I do not understand how the examples given in the Help regarding testing the return from a ShowDialog can work under these conditions, unless I am somehow declaring the 2nd form incorrectly.
 
B. Chernick said:
? No, either way I have a problem.

Sorry, I misunderstood "Under this setup, the code keeps on going without
delay after the ShowDialog call."
How do I detect that the 2nd
form has closed? All my reading so far about the ShowDialog method
seems to say that I should expect the application to come back to the
original code ONLY after the 2nd form has closed but in every example
I've run, it keeps on running.

What keeps on running?
I do not understand how the examples
given in the Help regarding testing the return from a ShowDialog can
work under these conditions, unless I am somehow declaring the 2nd
form incorrectly.


I'm still not sure if I understand you: Showdialog is executed, the form is
shown, you close the Form. The code after showdialog is not executed? The
form is not closed? What code is executed next after you close the Form? Is
the app responsive? Maybe the code is within a Try/Catch block and
exceptions are ignored? Do you have the Release configuration where
breakpoints are ignored? Did you try showing a msgbox after calling
showdialog?
 
B. Chernick said:
No. Now that I have the form calling code in a separate subroutine
(called from a button click), the code after the ShowDialog runs
immediately. It does not wait for the form to be closed. (It
failed to run when I called the form from a datagrid event. I assume
that is a separate problem.)

This is the current code. The message box comes up over the new form
at once.
Dim ce As New frmCustEdit
ce.ShowDialog(Me, "Update")
MsgBox("Test")

Ah, now I understand - I think.

Probably you are setting setting the Dialogresult property somewhere. This
makes ShowDialog return.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Ok, massive appologies to one and all in this forum. Stupid beginner's mistake

When I overloaded the ShowDialog sub (to accept a message field) in the 2nd form, I wrote me.Show rather than me.ShowDialog

Once again thanks for your patience and sorry to have wasted your time
 
B. Chernick said:
Ok, massive appologies to one and all in this forum. Stupid
beginner's mistake!

When I overloaded the ShowDialog sub (to accept a message field) in
the 2nd form, I wrote me.Show rather than me.ShowDialog.

Once again thanks for your patience and sorry to have wasted your
time.

Good to know that you found the solution.
 
Back
Top