Upraviť

Zdieľať cez


FormClosedEventArgs Class

Definition

Provides data for the FormClosed event.

public ref class FormClosedEventArgs : EventArgs
public class FormClosedEventArgs : EventArgs
type FormClosedEventArgs = class
    inherit EventArgs
Public Class FormClosedEventArgs
Inherits EventArgs
Inheritance
FormClosedEventArgs

Examples

The following code example demonstrates the use of this type. In the example, an event handler reports on the occurrence of the FormClosed event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing Show with Console.WriteLine or appending the message to a multiline TextBox.

To run the example code, paste it into a project that contains an instance of type Form named Form1. Then ensure that the event handler is associated with the FormClosed event.

private void Form1_FormClosed(Object sender, FormClosedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "FormClosed Event" );
}
Private Sub Form1_FormClosed(sender as Object, e as FormClosedEventArgs) _ 
     Handles Form1.FormClosed

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"FormClosed Event")

End Sub

Remarks

The FormClosed event occurs after 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. If a form has any child or owned forms, a FormClosed event is also raised for each one.

The FormClosedEventArgs class provides data for the FormClosed event. The CloseReason property provides the reason why the form is being closed.

Constructors

FormClosedEventArgs(CloseReason)

Initializes a new instance of the FormClosedEventArgs class.

Properties

CloseReason

Gets a value that indicates why the form was closed.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also