OnKeyUp anomaly

W

William Barnes

Using VS .NET 2003 on an up-to-date XP Pro machine:

I'm getting bizarre results in a VB Windows app trying to implement the
OnKeyUp event handler. I have a form with a label control and code simialr
to the following:

Protected Overrides Sub OnKeyUp(ByVal e As
System.Windows.Forms.KeyEventArgs)

Select Case e.KeyCode
Case Keys.Up
lblKeyVal.Text = "Up Arrow"
Case Keys.Enter
lblKeyVal.Text = "Enter"
Case Keys.Escape
lblKeyVal.Text = "Escape"
End Select

End Sub

When I run this code on a sample project with no other code in it it seems
to run fine. However, when I place this identical code into my development
project, strange things happen. When I press either the *Enter* or the
*Escape* key, it works as expected. However, as soon as I press the *Up
Arrow* key, the program ceases to respond to key presses. If I place a
breakpoint at the first line of the Sub, it breaks there for every *Enter*
and *Escape* keypress until the first time I press the *Up Arrow*. Pressing
the *Up Arrow* does not result in execution halting at the breakpoint, and
afterwards the *Enter* and *Escape* keys also fail to activate the
breakpoint.

Any ideas???

TIA

William Barnes
 
C

Chris

William said:
Using VS .NET 2003 on an up-to-date XP Pro machine:

I'm getting bizarre results in a VB Windows app trying to implement the
OnKeyUp event handler. I have a form with a label control and code simialr
to the following:

Protected Overrides Sub OnKeyUp(ByVal e As
System.Windows.Forms.KeyEventArgs)

Select Case e.KeyCode
Case Keys.Up
lblKeyVal.Text = "Up Arrow"
Case Keys.Enter
lblKeyVal.Text = "Enter"
Case Keys.Escape
lblKeyVal.Text = "Escape"
End Select

End Sub

When I run this code on a sample project with no other code in it it seems
to run fine. However, when I place this identical code into my development
project, strange things happen. When I press either the *Enter* or the
*Escape* key, it works as expected. However, as soon as I press the *Up
Arrow* key, the program ceases to respond to key presses. If I place a
breakpoint at the first line of the Sub, it breaks there for every *Enter*
and *Escape* keypress until the first time I press the *Up Arrow*. Pressing
the *Up Arrow* does not result in execution halting at the breakpoint, and
afterwards the *Enter* and *Escape* keys also fail to activate the
breakpoint.

Any ideas???

TIA

William Barnes

Are you handling anything in the OnKeyDown or ProcessCmdKey events?

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top