Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to insert value to datagridview from each text box without click on button add just press enter key ...
Posted

Subscribe to the KeyDown event of TextBox and handle inserting value into DataGridView logic if the key pressed is Enter key as shown below:
VB
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    If e.KeyCode = Keys.Enter Then
        'Do inserting value in to DataGridView here
    End If
End Sub
 
Share this answer
 
VB
Private Sub txtid_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtid.KeyPress
        If Asc(e.KeyChar) = 13 Then
            'Do inserting value in to DataGridView here
        End If


Note: 13 is the ascii equivalent of ENTER or RETURN KEY
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900