ToolStripDropDownClosingEventArgs.CloseReason プロパティ

定義

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

プロパティ値

ToolStripDropDownCloseReason 値のいずれか 1 つ。

次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの ToolStripDropDown.Closing 発生を報告します。 このレポートは、イベントが発生したタイミングを知るのに役立ち、デバッグに役立ちます。 複数のイベントまたは頻繁に発生するイベントを報告するには、 を Console.WriteLine に置き換えるかMessageBox.Show、複数行TextBoxにメッセージを追加することを検討してください。

コード例を実行するには、 という名前ToolStripDropDown1の型ToolStripDropDownのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーが イベントに関連付けられていることを確認します 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

適用対象