Ignoring a KeyDown Event on a DataGridView
Posted on 2007-10-04
I have the following sub on a form of my project:
Private Sub lnklblSupplier_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnklblSupplier.LinkClicked
If frmLookupSuppliers.ShowDialog = Windows.Forms.DialogResult.OK Then
txtboxSuppCode.Text = frmLookupSuppliers.dgvLookup.SelectedRows(0).Cells(0).Value
When the linklabel is clicked it opens another form with a populated DataGridView on it. I have set on the DGV form that when a user double clicks the DGV it passes the value from the clicked row back to the main form and this works fine. However, I also want the user to be able to press the Return key and have the selected value be returned to the main form.
The problem I am having is that when the user presses return and value that is being passed back is the following row from the DGV because the return keypress is moving the selection down one. Is there any way I can stop the return keypress moving the selection of the DGV?