Want to stop single-line text control beeping at me

This is a discussion on Want to stop single-line text control beeping at me within the C# Programming forums, part of the General Programming Boards category; The text control needs to be single line, and I've captured the KeyPress event for when Enter is pressed. This ...

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Want to stop single-line text control beeping at me

    The text control needs to be single line, and I've captured the KeyPress event for when Enter is pressed. This works fine, but the control beeps whenever Enter is pressed, even if I capture KeyDown as well. Is there a way to stop this behavior?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    Try this.
    Code:
    protected override bool ProcessDialogKey(System.Windows.Forms.Keys keyData)
    {
        if (keyData == System.Windows.Forms.Keys.Enter)
            return true;
    
        return base.ProcessDialogKey(keyData);
    }

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Works great, thanks. Can it be done without overriding a function?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    Not with version 1.x of the Framework, however with version 2.0 this isn't a problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading text file by line number
    By whiskedaway in forum C++ Programming
    Replies: 13
    Last Post: 06-16-2009, 10:09 AM
  2. reading a text file printing line number
    By bazzano in forum C Programming
    Replies: 4
    Last Post: 09-16-2005, 10:31 AM
  3. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 05:21 PM
  4. inputting line of text vs. integers in STACK
    By sballew in forum C Programming
    Replies: 17
    Last Post: 11-27-2001, 10:23 PM
  5. text line termination
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 09-09-2001, 04:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21