KeyEventArgs.SuppressKeyPress Özellik

Tanım

Anahtar olayının temel alınan denetime geçirilip geçirilmeyeceğini belirten bir değer alır veya ayarlar.

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

Özellik Değeri

true anahtar olay denetime gönderilmemelidir; aksi takdirde , false.

Örnekler

Aşağıdaki kod örneği, sayısal tuş vuruşlarının adlı textBox1denetime ulaşmasını TextBox engeller.

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9 && e.Modifiers != Keys.Shift)
    {
        e.SuppressKeyPress = true;
    }
}
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, _
    ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    
    If e.KeyCode >= Keys.D0 And e.KeyCode <= Keys.D9 And _
    e.Modifiers <> Keys.Shift Then
        e.SuppressKeyPress = True
    End If
End Sub

Açıklamalar

Kullanıcı girişini önlemek için gibi KeyDown bir olay işleyicisinde bu özelliğe atayabilirsiniztrue.

ayarı SuppressKeyPress olarak da ayarlanır Handledtrue.true

Şunlara uygulanır

Ayrıca bkz.