Saturn
Saturn

Reputation: 18169

Make the TabControl ignore my arrow key presses

I am doing some stuff when the user presses the arrow keys, but I fear many controls, like the TabControl, respond to such presses as well. In the case of my TabControl, the arrow presses will make it change of tab. I don't want that.. how can I disable such?

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyValue = 39 Then
        doSomethingAwesome
    End If
End Sub

Upvotes: 0

Views: 1490

Answers (1)

ChrisF
ChrisF

Reputation: 137198

Set e.Handled = true.

This tells any subsequent handlers that the key press has been dealt with.

Upvotes: 2

Related Questions