tags:

views:

88

answers:

2

I've been using ShowDialog() in following way for all my new Windows.

SomeGui test = new SomeGui();
test.ShowDialog();
refreshSomeListView();

However recently I've started to use Show() instead of ShowDialog() and it's working much better. The only drawback of this is that refreshSomeListView(); cannot be used like in example above since if i leave it there it's executed instantly when new Window shows up.

What's the best way to know that the user has closed test window and that now refreshSomeListView(); should be executed? What's suggested approach for this? Should it involve setting events in test GUI on Close/Closing or there's other / better method?

+8  A: 

You can subscribe to the Form.Closed event and perform refresh in its handler. Here is MSDN description of this event.

Andrew Bezzub
Nice, it works. You could update your answer with some code example for future reference.
MadBoy
Code examples are hardly necessary for basic answers to basic questions.
Charles Boyung
Despite Charles not seeing the need, here's link to code example for future reference http://www.dotnetcurry.com/ShowArticle.aspx?ID=125
MadBoy
A: 

In VB.Net:

Dim test as new SomeGui()
AddHandler test.Closed, AddressOf refreshSomeListView
test.Show
Garcia Julien