Thread: Want to stop single-line text control beeping at me

  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?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Banal internet user
    Join Date
    Aug 2002
    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?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    Banal internet user
    Join Date
    Aug 2002
    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, 06:21 PM
  4. inputting line of text vs. integers in STACK
    By sballew in forum C Programming
    Replies: 17
    Last Post: 11-27-2001, 11:23 PM
  5. text line termination
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 09-09-2001, 04:39 AM