Problem with keyevent and buttons

  • Thread starter Thread starter Tomas Andersson
  • Start date Start date
T

Tomas Andersson

I created a form that has KeyPreview enabled
On this form threre is four groupboxes
and some buttons in one of the GBoxes

the keyevent works fine on all keys exept Return.
And if i remove the buttons from the form the return event works.

How do I keep the buttons and get the form to respond to Return?
Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode <= 32 Then
Call RemoveButtons()
e.Handled = True
Else
a = a + Chr(e.KeyValue.ToString)
e.Handled = True
End If
End sub
 
Tomas Andersson said:
I created a form that has KeyPreview enabled
On this form threre is four groupboxes
and some buttons in one of the GBoxes

the keyevent works fine on all keys exept Return.
And if i remove the buttons from the form the return event works.

How do I keep the buttons and get the form to respond to Return?
Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode <= 32 Then
Call RemoveButtons()
e.Handled = True
Else
a = a + Chr(e.KeyValue.ToString)
e.Handled = True
End If
End sub


I can't reproduce the problem. I don't get the enter key in keydown only if
the Form's Acceptbutton property is set. But that's ok because Enter is to
be handled by the button's click event, then. Otherwise Enter also arrives
at keydown.


Armin
 
Acceptbutton property is set to (none)




Armin Zingler said:
I can't reproduce the problem. I don't get the enter key in keydown only
if the Form's Acceptbutton property is set. But that's ok because Enter is
to be handled by the button's click event, then. Otherwise Enter also
arrives at keydown.


Armin
 
Back
Top