I am trying to show a form using Form.ShowDialog as shown below:
var f = new Form();
if(f.ShowDialog() == DialogResult.OK)
{
...
}
...
if(f.ShowDialog() == DialogResult.OK)
{
...
}
The issue is the OnHandleDestroyed is called once a dialog result is returned and the form is closed.
- Why do I care about OnHandleDestroyed? I have an OpenGL control on the form, and it disposes the Context when OnHandleDestroyed is called.
- Why don't I dispose of the form, and use ShowDialog on the new form? I am trying to reuse the form as loading the form is slow - but populating it with data is quick.
So the question is: Is it possible to use ShowDialog() without closing the form (and hiding it instead) OR to show a form modally using Show() and Hide()?