How Do i prevent beep sound in numericupdown while pressing enter key?

How Do i prevent beep sound in numericupdown while pressing enter key

Answer this question

How Do i prevent beep sound in numericupdown while pressing enter key?

  • Ton vd Pol

    Hi Andrej

    Sorry pal , i am using .net 1.1

    i have written this code ,

    but not working

    Private Sub numericContourLevel_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles numericContourLevel.KeyDown

    If e.KeyCode = Keys.Return Then

    e.Handled = True

    End If

    End Sub


  • daydreamsy2k

    How about setting your form's KeyPreview to True and suppressing Return key on form's level, when NumericUpDown control has a focus (indicating user is entering text in it)

    Private Sub Form1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
       
    If e.KeyChar = vbCr And NumericUpDown1.Focused Then
           
    e.Handled = True
       
    End If
    End Sub

    Andrej



  • Matt MacDonald

    Hi,

    see if the following code works for you:

    private void numericUpDown1_KeyDown(object sender, KeyEventArgs e)
    {
    if (e.KeyCode == Keys.Return)
    {
    e.SuppressKeyPress =
    true;
    }
    }

    Andrej



  • stiflersmom100

    It's not that different... are you using .NET 2.0 If, yes, this is the code:

    Private Sub NumericUpDown1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NumericUpDown1.KeyDown
       
    If e.KeyCode = Keys.Return Then
           
    e.SuppressKeyPress = True
       
    End If
    End Sub

    Andrej



  • Vijay R

    Hi Andrej,

    Thanks for replying , one more quetion

    how do i handle this thing in vb.net.

    Thanks

    Saurabh


  • How Do i prevent beep sound in numericupdown while pressing enter key?