How to detect when window is closed when using Show() in WinForms C#

Posted by MadBoy on Stack Overflow See other posts from Stack Overflow or by MadBoy
Published on 2010-03-17T12:21:48Z Indexed on 2010/03/17 12:31 UTC
Read the original article Hit count: 456

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms