Select DataGridView row with Enter and send record to TextBox

0

I can not select with the Enter key a record of the DataGridView to be able to send it to text boxes.

This process has already been done by clicking on the row and I have not had any problem; now that I occupy doing it giving Enter, it simply does not work to me, nothing happens, the registry is not shown in the Text Box.

I show my code so you can tell me what I'm missing.

Private Sub DataGridView1_KeyDown(sender As Object, e As KeyEventArgs) Handles DataGridView1.KeyDown
    Dim fila As Integer
    fila = DataGridView1.CurrentRow.Index
    If e.KeyCode = Keys.Enter Then
        e.SuppressKeyPress = True
        UsuariosAdmon.TextBox1.Text = Me.DataGridView1.Item(0, fila).Value
        UsuariosAdmon.TextEdit3.Text = Me.DataGridView1.Item(1, fila).Value
        Me.Close()
    End If
End Sub

This code is in the KeyDown event of the DataGrid.

I'm using VS 2015 Enterprise

    
asked by Jonsin 11.06.2018 в 20:06
source

0 answers