Refreshing Parent window from child window

J

Jeff

I have a Form parent window with a list view on it.
When I click on an item I open another form to edit the details - this
is not and cannot be a dialog window.

When I close the child window I would like the parent window to
automatically refresh by calling a method RefreshData().

How can I achieve this.

Regards
Jeff
 
A

Alberto Poblacion

Jeff said:
I have a Form parent window with a list view on it.
When I click on an item I open another form to edit the details - this is
not and cannot be a dialog window.

When I close the child window I would like the parent window to
automatically refresh by calling a method RefreshData().

How can I achieve this.

In the parent form you are probably opening the child form in a way
similar to this:

MyEditForm frm = new MyEditForm();
frm.Show();

In between those lines, you can add an event handler to the form:

frm.Closed += new EventHandler(RefreshData);

This connects your "RefreshData" routine to the Closed event of the
form, so when the form is closed your method will be called as you wanted.
Note that for this to compile, the RefreshData method needs to have the
proper signature for an EventHandler, i.e. void RefreshData(object sender,
EventArgs e).
 

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

Top