How to prevent or block closing a WinForms window?

后端 未结 8 711
情书的邮戳
情书的邮戳 2020-12-01 04:01

How can I prevent window closing by showing a MessageBox? (Technology:WinForms with C#)

When the close event occurs I want the

8条回答
  •  时光取名叫无心
    2020-12-01 04:34

    Within your OnFormClosing event you can show the dialog and if answer is false (to not show) then set the Cancel property of the EventArgs to true.

提交回复
热议问题