how to trace arrow keys in a button in compact framework

  • Thread starter Thread starter raju
  • Start date Start date
R

raju

Hai,

How to trace (intercept), whether the user pressing arrow keys( 4
- left, right, up or down)
in a button, using compact framework.


In my application, i am using 8 buttons in a form. I need to move
from one button to another using only, left or right arrow keys. when i
press other keys, there is no action in that button.

In my code, i try with keycode property in keydown event and
keyvalue property in keypress event. But it doesn't work for the button
control. It is fine for other controls.

Any one know the answer pl. let me know.


Regards,
Raju.
 
Seems to me you need to keep track of which of the eight buttons you are on.
Then use the code below.

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If (e.KeyCode = System.Windows.Forms.Keys.Left) Then
'Left
'put code here to move to the button on the left of the present
one
End If

If (e.KeyCode = System.Windows.Forms.Keys.Right) Then
'Right
'put code here to select the next buton on the right of the present
one
End If

End Sub
 
William said:
Seems to me you need to keep track of which of the eight buttons you are on.
Then use the code below.

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If (e.KeyCode = System.Windows.Forms.Keys.Left) Then
'Left
'put code here to move to the button on the left of the present
one
End If

If (e.KeyCode = System.Windows.Forms.Keys.Right) Then
'Right
'put code here to select the next buton on the right of the present
one
End If

End Sub


hai William LaMartin,

Thanks for your answer.

I tried my application with the code given by you.

Its working properly. thanking you.
 
Back
Top