Results 1 to 4 of 4

Thread: How can I skip the alert sound when hitting enter

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2013
    Posts
    42

    How can I skip the alert sound when hitting enter

    I have a modal form with a text box and a enter button. After typing in the textbox, I hit enter and there is a alert or bell sound and it does not press the button. My tab order is textbox then button and form keypreview is set to true. How can I avoid the annoying sound?

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: How can I skip the alert sound when hitting enter

    there is a alert or bell sound and it does not press the button
    Is there a code in your app that triggers the alert sound?
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: How can I skip the alert sound when hitting enter

    You can stop that sound by setting e.Handled to True in the Keypress event handler of the TextBox.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: How can I skip the alert sound when hitting enter

    Hi,

    Have a go with this snippet of code in the KeyDown Event of the Form:-

    vb.net Code:
    1. Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    2.   If e.KeyCode = Keys.Enter Then
    3.     e.SuppressKeyPress = True
    4.     ProcessTabKey(True)
    5.   End If
    6. End Sub

    Hope that helps.

    Cheers,

    Ian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width