KeyEventArgs.SuppressKeyPress 속성

정의

키 이벤트를 내부 컨트롤에 전달할지 여부를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

키 이벤트를 컨트롤에 보내지 않으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 숫자 키 입력이 라는 textBox1컨트롤에 TextBox 도달하지 못하도록 합니다.

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

설명

사용자 입력을 방지하기 위해 과 같은 KeyDown 이벤트 처리기에서 이 속성에 할당 true 할 수 있습니다.

를 로 설정 SuppressKeyPress 하여 true 를 로 true설정합니다Handled.

적용 대상

추가 정보