SaintJimmy
Member
- Joined
- Jul 7, 2006
- Messages
- 24
- Programming Experience
- 5-10
This may be a really simple question, but I can't get it to work for some reason.
I've got a form with a datagrid control on it. And I want the datagrid to relenquish focus to the next control in the tab order when the user hits the tab key, rather than the default behavior of tabbing to the next cell. Here's the procedure I wrote to attempt this, but it only works for tabbing to the previous control (when shift+tab is used). What am I doing wrong here?
I've got a form with a datagrid control on it. And I want the datagrid to relenquish focus to the next control in the tab order when the user hits the tab key, rather than the default behavior of tabbing to the next cell. Here's the procedure I wrote to attempt this, but it only works for tabbing to the previous control (when shift+tab is used). What am I doing wrong here?
VB.NET:
Private Sub dgCustomers_KeyUp(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles dgCustomers.KeyUp
If e.KeyCode = Keys.Tab Then
Dim nextctl As Control
If e.Shift Then
nextctl = Me.GetNextControl(dgCustomers, False)
nextctl.Focus()
Else
nextctl = Me.GetNextControl(dgCustomers, True)
nextctl.Focus()
End If
End If
End Sub