How can I disable the Page Down/Up, when the Focus in on a Button?

221 Views Asked by At

I have a program that can change values in a database. I have a TrueDBGrid in my form and the Page Down/Up works fine. If I click on a button with TAB, this Page Down/Up still works. How can I prevent this when the focus is on the button?

1

There are 1 best solutions below

0
On BEST ANSWER

I've found a solution. That would be:

Private Sub frmZeitcodeListe_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
    Try

        If e.KeyCode = Keys.PageUp Then
            If cmdBearbeiten.Focused = True Or cmdLoeschen.Focused = True Or cmdNeu.Focused = True Or cmdSchliessen.Focused = True Then
                e.Handled = False
            Else
                bsTblZeitcode.MovePrevious()
                e.Handled = True
            End If

        ElseIf e.KeyCode = Keys.PageDown Then
            If cmdBearbeiten.Focused = True Or cmdLoeschen.Focused = True Or cmdNeu.Focused = True Or cmdSchliessen.Focused = True Then
                e.Handled = False
            Else
                bsTblZeitcode.MoveNext()
                e.Handled = True
            End If
        End If

    Catch ex As Exception
    End Try
End Sub