Reputation: 149
I want to get the value of the first cell of a row in the datagridview on selecting any cell of the row of the datagridview and pressing enter. How to do it?
Upvotes: 0
Views: 1461
Reputation: 1404
You may handle DataGridView.KeyDown event. For example:
object firstCellValue = null;
private void dgv_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
firstCellValue = dgv.Rows[dgv.CurrentCell.RowIndex].Cells[0].Value;
}
}
Upvotes: 1