Share via


PreviewKeyDownEventArgs.KeyValue Özellik

Tanım

Veya KeyDownKeyUp olayının klavye değerini alır.

public:
 property int KeyValue { int get(); };
public int KeyValue { get; }
member this.KeyValue : int
Public ReadOnly Property KeyValue As Integer

Özellik Değeri

Int32 Klavye değerini temsil eden bir.

Örnekler

Aşağıdaki kod örneğinde bu üyenin kullanımı gösterilmektedir. Örnekte, bir olay işleyicisi olayın oluşumunu Control.PreviewKeyDown raporlar. Bu rapor, olayın ne zaman gerçekleştiğini öğrenmenize yardımcı olur ve hata ayıklamada size yardımcı olabilir. Birden çok olayı veya sık gerçekleşen olayları raporlamak için, iletisini ile Console.WriteLine değiştirmeyi MessageBox.Show veya çok satırlı TextBoxbir iletiye eklemeyi göz önünde bulundurun.

Örnek kodu çalıştırmak için, veya gibi türünden Controldevralan bir türün örneğini içeren bir ButtonComboBoxprojeye yapıştırın. Ardından örneği Control1 adlandırın ve olay işleyicisinin olayla ilişkilendirildiğinden Control.PreviewKeyDown emin olun.

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

Şunlara uygulanır