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?
Asked
Active
Viewed 192 times
0
-
1Will you please clarify your question. WinForm or WPF project?, What is the _Page Down/Up_? Give us something mate to understand your logic. – Oct 17 '19 at 14:47
-
WinForms, PageUp and PageDown is on the keyboard. Do the same as arrow up or down. – a.b_om Oct 21 '19 at 06:35
-
I see. Now how about you [Edit](https://stackoverflow.com/posts/58434762/edit) your question to include some code related to the problem so we can understand then we could help. Please check: https://stackoverflow.com/help/how-to-ask – Oct 21 '19 at 06:58
-
There is no exception. I just want to know how it works. – a.b_om Oct 21 '19 at 07:09
1 Answers
0
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

a.b_om
- 91
- 9