sandya_116
asked on
datagridview disable tab
How can I disable the user from pressing tab in a datagridview or when user presses tab, I don't want the selection to move from the current row to the new row. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks jpaulino. That worked. I don't know if I have to open a new post but how can I disable the user from pressing down and up arrows in the grid as I just want the rows to b highlighted only when user clicks on a cell.
You can do it in the same way. Please confirm the Keys.Up and Keys.Down because right now I cannot test it.
If e.KeyCode = Keys.Tab or e.KeyCode = Keys.Down or e.KeyCode = Keys.Up Then
e.Handled = True
End If
If e.KeyCode = Keys.Tab or e.KeyCode = Keys.Down or e.KeyCode = Keys.Up Then
e.Handled = True
End If
ASKER
Thanks. That worked perfectly.
If you want to disable the user from pressing tab in a datagridview or when the user presses tab, if you don't want the selection to move from the current row to the new row then in the keypress event of the datagridview reset the keyascii value of the tab key to 0. For example
Private Sub DataGrid1_KeyPress(KeyAsci
If KeyAscii = 9 Then KeyAscii = 0
End Sub
Hope this might help you.
by
D.Shanmuga Sundaram