Click here to Skip to main content
15,891,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want select data from datagrideview ,but it is only possibal on mouse click i want to select data on enter press ,plz. help me .
following code only permit to select data by mouse click

What I have tried:

Private Sub dgvprod_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvprod.CellContentClick
      If e.RowIndex < 0 OrElse e.ColumnIndex < 0 Then Exit Sub
      ' SELECT USERNAME FROM COLUMN 1 OF ROW CLICKED
      select_prod(dgvprod.Item("product_name", e.RowIndex).Value)
  End Sub
Posted
Updated 27-Oct-17 4:15am
v2

1 solution

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
  if (e.KeyCode.Equals(Keys.Enter))
  {
    DataGridViewRow dgr = dataGridView1.CurrentRow;
    string column0 = dgr.Cells[0].Value.ToString();
  }
}


convert this to your vb.net code over...
 
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