Setting programmatically closereason

后端 未结 4 695
你的背包
你的背包 2021-02-19 10:25

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

4条回答
  •  日久生厌
    2021-02-19 10:54

    Rather than creating the extra variable:

    appClosing = true; 
    this.Close();
    

    You can call:

    Application.Exit();
    

    And then e.CloseReason will equal

    CloseReason.ApplicationExitCall
    

    Which might be what you're after.

提交回复
热议问题