ToolStripDropDownClosedEventArgs.CloseReason Właściwość

Definicja

Pobiera przyczynę zamknięcia ToolStripDropDown .

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.Closed 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.Closed .

private void ToolStripDropDown1_Closed(Object sender, ToolStripDropDownClosedEventArgs e) {

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

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

End Sub

Dotyczy