e.SuppressKeyPress = True not working

ideprize

Well-known member
Joined
Oct 19, 2011
Messages
96
Programming Experience
10+
I have a simple three control Form; 1 label, 1 textbox, 1 button. I added the button for VB.Net becomes somewhat unstable with only one "active" control. The form "dings" every time "enter" is input to terminate the textbox entry prior to the transfer to the button control. I did research on the web and found numerous claims that the way to "stop the ding" is by placing "e.SuppressKeyPress = True" in the keyUP event for the textbox. The process being once that event senses a "Return/Enter" key it executes the e.SuppressKeyPress = True" command and then it executes the " SendKeys.Send(vbTab)" command. The tab key simply causes the transfer to the "Quit Button" without the ding. I have also tried adding the e.handled = true command as well but "no cigar". I have reduced this problem to as simple a test case as possible and have attached the VB code for inspection to see perhaps what I am not understanding. I am not a "newbie" to VB.Net so this is really rather perplexing. Any insights that can be provided will be greatly appreciated.

Respectfully,
Ideprize
 

Attachments

  • form1.txt
    1,015 bytes · Views: 23

ideprize

Well-known member
Joined
Oct 19, 2011
Messages
96
Programming Experience
10+
That indeed was the solution JohnH. For the sake of knowledge could you profile the "response window" that occurs in the KeyDown event that does not occur in the KeyUp event. I mean talk about forensic! Thanks a lot sir.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,439
Location
Norway
Programming Experience
10+
Enter is a navigation key that is forwarded to the forms AcceptButton, and when there is no accept button on form user is alerted. This probably happen in KeyPress, and since order is KeyDown-KeyPress-KeyUp you need to use the first.
 

ideprize

Well-known member
Joined
Oct 19, 2011
Messages
96
Programming Experience
10+
Thanks for the insights. I realized that KeyDown preceded KeyUp (by definition) but really wasn't sure about KeyPress. Again thanks for the help.

Respectfully
Ideprize
 
Top Bottom