Hi thescripts people, I hope I'm in the right forum for Visual Basic Dotnet (VS 2005).
I am trying to make a custom control in which you can nudge a point around using the arrow keys. Actually, the control is meant to be a simple drawing program. To test it out I have put the control on a Windows form which also contains several buttons.
I have added a KeyDown event handler to the custom control (see code below). It responds fine to keys like Enter or Shift-X, but not to the arrow keys. Pressing an arrow key just jumps from one button on the test form to the next. It does not even get into my KeyDown handler.
In fact, I'd like to handle any possible key or key combination in my custom control, and not in the form. Perhaps I'm missing something obvious. Can anyone tell me how to do it?
thanks in advance, BB
Here's the code of a test version of the KeyDown handler:
Private Sub Drawing_Sheet_K eyDown(ByVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.Left
m_PointLocation .X -= 1
Case Keys.Right
m_PointLocation .X += 1
Case Keys.Up
m_PointLocation .Y -= 1
Case Keys.Down
m_PointLocation .Y += 1
'debugging tests:
Case Keys.Enter
MsgBox("Enter pressed")
Case Keys.X
If e.Modifiers = Keys.Shift Then MsgBox("Shift x pressed") Else MsgBox("x pressed")
End Select
End Sub