System.Windows.Forms.FormClosingEventArgs Class

Provides data for the Form.FormClosing event.

See Also: FormClosingEventArgs Members

Syntax

public class FormClosingEventArgs : System.ComponentModel.CancelEventArgs

Remarks

The Form.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 Form.Close in the System.Windows.Forms.Form class, or Application.Exit in the System.Windows.Forms.Application class.

If a form has any child or owned forms, a Form.FormClosing event is also raised for each one. If any one of the forms cancels the event, none of the forms are closed. Therefore the corresponding Form.FormClosed events are not sent to any of the forms.

The System.Windows.Forms.FormClosingEventArgs class provides data for this event. Two important members are the System.ComponentModel.CancelEventArgs.Cancel and FormClosingEventArgs.CloseReason properties. The event can be canceled by setting the System.ComponentModel.CancelEventArgs.Cancel property to true. The FormClosingEventArgs.CloseReason property provides a reason why the form is being closed.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0