c# - How can you determine whether a form has been closed by the user or by your code? -


I have a form (let's call it as parent), of which "always not on top but rather modal "The form can be filled (like a dialogue, but a dialogue - the user can leave the new" child form "where he is and continues to work as a parent).

When the user opens for the first time, some data is loaded and displayed to the child. Do they close the form, I actually block the lock and just hide the form - so that they can open it next time, we do not need to reload the data (this is not the data that changes at all is).

  if (e.CloseReason == CloseReason.UserClosing) {E.Canel = true; This.Hide (); }  

Later, when the parent's form closes, I want to force the child to close the form properly - next time its location and size is stored To do this, it has to run some base code. / P>

Currently I call childForm.Dispose () from the nature of the parent who cleans the thing well, but does not give me more control.

However, if I call the child. Close () method, e. Closerson is still "CloseReason.UserClosing".

Is there a way to differentiate between the user form and closing my code (basically) shutting it down?

Just a special " in fact close () And it is said that when you really want to close the form.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -