Question Custom control loses focus when key is pressed

Adagio

Well-known member
Joined
Dec 12, 2005
Messages
162
Programming Experience
Beginner
This is getting quite annoying and I'm currently lost (google didn't return anything useful)

I have a form with two items:
A custom control
A datetimepicker


When the custom control is in focus and I click the arrow keys the datetimepicker is given focus. This causes the date to change and the custom control never receives the key input

How do I make the datetimepicker mind it's own business?
 
Last edited:
I managed to find the solution:

Private Sub LagerList_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles MyBase.PreviewKeyDown
If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Then
e.IsInputKey = True
End If
End Sub
 
Back
Top