I do not want the form to exit when the “close window” option is clicked in the menu that pops up when the taskbar button is right clicked. Instead, I want the application to be minimized to the system tray.
How do I change the behavior of the “Close Window”?
I do not want the form to exit when the close window option is
Share
Add an override of
OnFormClosingand look at theCloseReasonof the event arguments parameter. Maybe something like this:This way, the user cannot close your form (only hide it), but Windows still can for other reasons (e.g. shutdown).