PreviewKeyDownEventArgs.IsInputKey Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy klucz jest zwykłym kluczem wejściowym.

public:
 property bool IsInputKey { bool get(); void set(bool value); };
public bool IsInputKey { get; set; }
member this.IsInputKey : bool with get, set
Public Property IsInputKey As Boolean

Wartość właściwości

true jeśli klucz jest zwykłym kluczem wejściowym; w przeciwnym razie , false.

Przykłady

Poniższy przykład kodu przedstawia użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie zdarzenia Control.PreviewKeyDown . Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub zdarzeń, które występują często, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączeniem go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu dziedziczonego z Controlelementu , takiego jak Button lub ComboBox. Następnie nadaj wystąpieniu Control1 nazwę i upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem Control.PreviewKeyDown .

private void Control1_PreviewKeyDown(Object sender, PreviewKeyDownEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Alt", e.Alt );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Control", e.Control );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyCode", e.KeyCode );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyValue", e.KeyValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyData", e.KeyData );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Modifiers", e.Modifiers );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Shift", e.Shift );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "IsInputKey", e.IsInputKey );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "PreviewKeyDown Event" );
}
Private Sub Control1_PreviewKeyDown(sender as Object, e as PreviewKeyDownEventArgs) _ 
     Handles Control1.PreviewKeyDown

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Alt", e.Alt)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Control", e.Control)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyCode", e.KeyCode)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyValue", e.KeyValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyData", e.KeyData)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Modifiers", e.Modifiers)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Shift", e.Shift)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "IsInputKey", e.IsInputKey)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"PreviewKeyDown Event")

End Sub

Dotyczy