Search results
14 cze 2015 · Use Form1_FormClosing event and also don't use Application.Exit() like this: var x = MessageBox.Show("Are you sure you want to really exit ? ", . "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (x == DialogResult.No) . e.Cancel = true; else. e.Cancel = false; Or like this:
When a form is closed, it is disposed, releasing all resources associated with the form. If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the FormClosingEventArgs passed to your event handler to true.
This event occurs after the form has been closed by the user or by the Close method of the form. To prevent a form from closing, handle the Closing event and set the Cancel property of the CancelEventArgs passed to your event handler to true.
The FormClosing event occurs just before a form is closed, either by the user, through the user interface (UI), or programmatically, through calls to methods such as Close in the Form class, or Exit in the Application class. This event can be canceled.
23 lip 2024 · The simplest and most common way to close a Windows Form in C# is by using the Close method. This method triggers the FormClosing event before closing the form. Here is an example of how you can close a form using the Close method:
16 lut 2024 · The most straightforward way to close a form in C# is by using the Close() method. This method is inherited from the System.Windows.Forms.Form class and is available for Windows Forms and WPF applications.
23 lip 2024 · In this blog post, we will explore different methods to close the current form in C#. Using the Close Method. The simplest way to close the current form is by calling the Close method. This method closes the form and releases all resources associated with it. this.Close(); Using Application.Exit. Another approach is to use Application.Exit ...