QueryContinueDragEventArgs.EscapePressed 屬性

定義

取得使用者是否按下 ESC 鍵。

public:
 property bool EscapePressed { bool get(); };
public bool EscapePressed { get; }
member this.EscapePressed : bool
Public ReadOnly Property EscapePressed As Boolean

屬性值

如果按下 ESC 鍵,則為 true,否則為 false

範例

下列程式碼範例示範 如何使用 EscapePressed 。 在此範例中,事件處理常式會報告事件發生次數 Control.QueryContinueDrag 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 為 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼到包含繼承自 Control 之型別實例的專案,例如 ButtonComboBox 。 然後命名 實例 Control1 ,並確定事件處理常式與事件相關聯 Control.QueryContinueDrag

private void Control1_QueryContinueDrag(Object sender, QueryContinueDragEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "KeyState", e.KeyState );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "EscapePressed", e.EscapePressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "QueryContinueDrag Event" );
}
Private Sub Control1_QueryContinueDrag(sender as Object, e as QueryContinueDragEventArgs) _ 
     Handles Control1.QueryContinueDrag

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

End Sub

備註

根據預設,如果 為 true,則 QueryContinueDrag 事件會設定 ActionDragAction.CancelEscapePressed

適用於

另請參閱