QueryContinueDragEventArgs.EscapePressed Egenskap

Definition

Hämtar om användaren tryckte på ESC-tangenten.

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

Egenskapsvärde

trueom ESC-tangenten trycktes på; annars . false

Exempel

Följande kodexempel visar användningen av EscapePressed . I exemplet rapporterar en händelsehanterare om händelsens Control.QueryContinueDrag förekomst. Den här rapporten hjälper dig att lära dig när händelsen inträffar och kan hjälpa dig att felsöka. Om du vill rapportera om flera händelser eller händelser som inträffar ofta kan du överväga att MessageBox.Show ersätta med Console.WriteLine eller lägga till meddelandet i en flerradig TextBox.

Om du vill köra exempelkoden klistrar du in den i ett projekt som innehåller en instans av en typ som ärver från Control, till exempel en Button eller ComboBox. Namnge sedan instansen Control1 och se till att händelsehanteraren är associerad med Control.QueryContinueDrag händelsen.

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

Kommentarer

Som standard QueryContinueDrag anges Action händelsen till DragAction.Cancel om EscapePressed är sant.

Gäller för

Se även