I want the x button in the title bar to close the entire application, not the current form. How to do it?
Attach an event handler for the FormClosed event on the form and call Application.Exit() . For instance:
FormClosed
Application.Exit()
private void Form2_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); }
@rsbarro is right, however I want to be more specific.
private void Form_FormClosed(object sender, FormClosingEventArgs e) { // if close button clicked, not the computer is being shutdown or anyother reason if (e.CloseReason == CloseReason.UserClosing) { Application.Exit(); } }
Source: https://habr.com/ru/post/1343552/More articles:Why is Bash s $ RANDOM not sown (?) On some machines? - bashhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1343548/prototype-are-there-ajax-startstop-events-to-global-trigger-an-ajax-modal-wait-message&usg=ALkJrhiTHHXY5NhZGuxTjckBkVw_sB19QwiPhone: How do I play a sound that ignores the volume and ringer settings? - iphoneSimple Vim Programming (vimrc file) - vimIs there a length limit for String in Android? - javaHow do you spin around something? - javascriptGeocoding and Google Maps V3 markers in a loop - javascriptasp.net mvc user load testing - asp.net-mvcLink to C functions in a static library from C ++ - c ++Is this method faster than Math.random ()? - javaAll Articles