[RESOLVED] nullify {tab} key action
with vb.net 05 + datagridview
in my datagidview i am having a button column
i want the button to execute some actions when the enter button is pressed
but if i press the enter button tab key action coming in to force i,e focus is getting shifted to next row hence i want to lock the tab key action and let the button to its click event job
how to do it please
and any adverse effect please advise
Re: nullify {tab} key action
How about using the keydown event of the datagrid?
Code:
Private Sub dg_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dg.KeyDown
If e.KeyCode = Keys.Return Then
MessageBox.Show("enter pressed. do stuff here")
e.Handled = True
End If
End Sub
Re: nullify {tab} key action
thanks for reply
what job this line will do, does it triggering the click event :
my intention is to trigger some action, as if i am clicking the button
Re: nullify {tab} key action
Setting it to true bypasses the default handling of the enter key, which would be to move to the next row. I believe you'd trigger the action you want on the line where I've displayed the messagebox.
Re: nullify {tab} key action
The e.Handled = True line says that the actions to be carried out by this keypress have been done and that the default action doesn't get run. So if you didn't add that line then your code would run and then the default tab action would be carried out.
You can find out more about it here.
Re: nullify {tab} key action
thanks for reply & good material