ToolStripDropDownClosingEventArgs.CloseReason Właściwość

Definicja

Pobiera przyczynę ToolStripDropDown zamknięcia.

public:
 property System::Windows::Forms::ToolStripDropDownCloseReason CloseReason { System::Windows::Forms::ToolStripDropDownCloseReason get(); };
public System.Windows.Forms.ToolStripDropDownCloseReason CloseReason { get; }
member this.CloseReason : System.Windows.Forms.ToolStripDropDownCloseReason
Public ReadOnly Property CloseReason As ToolStripDropDownCloseReason

Wartość właściwości

ToolStripDropDownCloseReason Jedna z wartości.

Przykłady

W poniższym przykładzie kodu pokazano użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie ToolStripDropDown.Closing zdarzenia. Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie, i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub często występujących zdarzeń, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączenie go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu ToolStripDropDown o nazwie ToolStripDropDown1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem ToolStripDropDown.Closing .

private void ToolStripDropDown1_Closing(Object sender, ToolStripDropDownClosingEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Closing Event" );
}
Private Sub ToolStripDropDown1_Closing(sender as Object, e as ToolStripDropDownClosingEventArgs) _ 
     Handles ToolStripDropDown1.Closing

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

End Sub

Dotyczy