I want to set the CloseReason of a form after I call This.Close() inside the form.
Usually, this forms is closed by itself calling This.Close(), but I want to ask the us
CloseReason is an enum with the following members:
None
WindowsShutDown
MdiFormClosing
UserClosing
TaskManagerClosing
FormOwnerClosing
ApplicationExitCall
Which leads me to believe that it is dependent on conditions related to the behavior of forms in general (ex. closing a parent form closes it's childs). So in order for the arg to have say, the CloseReason.ApplicationExitCall, the event must be triggered from a Application.Exit call.
Same with say a CloseReason.FormOwnerClosing, assuming your child forms are called using form.Show(Parent)
If your goal is to simply have extra information of why the form is closing, you can simply store it inside the form object as a public attribute or property to access it later, assuming said form wasn't disposed.
Providing what was your motivation in changing the CloseReason would probably help, as well.
CloseReason msdn page for reference http://msdn.microsoft.com/en-us/library/system.windows.forms.closereason.aspx