Home All Groups Group Topic Archive Search About

How to detect when ShowDialog object has closed? (2003)

Author
4 Apr 2006 3:47 PM
Aziz
Here's the problem.
On my OrderForm the user can click a link to open up the AddCustomer
form to add a new customer, when AddCustomer form closes, it saves the
customer to the DataBase. The AddCustomer form is currently opened as a
Modal form using ShowDialog.

At the moment to see the newly added customer (in a ComboBox)I have to
click a button to close, then re-open the OLEDbConnection, re-fill the
DataSet then call the ComboBox fill method again. How do I enable it so
these commands are done automaticaly when the AddCustomer form closes?
Bear in mind that the AddCustomer form can itself be also loaded from
the MainMenu.

I tried the OrderForm's Got_Focus event but that doesn't work.

Any ideas?

Author
4 Apr 2006 3:56 PM
asad.naeem
Aziz as i understand ur problem, use datasets for this purpose. When
the record is inserted successfully, return its result as dataset and
add the value in the combobox otherwise dont insert it.
Author
4 Apr 2006 4:13 PM
Aziz
My fault for not being more clear.

Basically what I want to know is if I Open Form2 from Form1 using
ShowDialog, how can Form1 know when Form2 has closed?
Author
4 Apr 2006 4:26 PM
Kerry Moorman
Aziz,

When you show the form with ShowDialog your code waits until the shown form
is closed and then continues with the next line of code after the ShowDialog.

So after the line of code that shows the form, have a line of code that
clicks the button that you are currently clicking manually.

Kerry Moorman


Show quoteHide quote
"Aziz" wrote:

> My fault for not being more clear.
>
> Basically what I want to know is if I Open Form2 from Form1 using
> ShowDialog, how can Form1 know when Form2 has closed?
>
>
Author
4 Apr 2006 5:06 PM
VJ
AddHandler Form2.Closed, Addressof frm_Closed
Form2.ShowDialog()

private sub frm_Closed(sender as object , e as EventArgs)

    // Write code here to do things when Form2 is closed...

end sub

Show quoteHide quote
"Aziz" <aziz***@googlemail.com> wrote in message
news:1144167181.474040.222650@t31g2000cwb.googlegroups.com...
> My fault for not being more clear.
>
> Basically what I want to know is if I Open Form2 from Form1 using
> ShowDialog, how can Form1 know when Form2 has closed?
>