You can do like this:
private void datagridview1_SelectionChanged(object sender, EventArgs e)
{
if (datagridview1.SelectedCells.Count > 0)
{
int selectedrowindex = datagridview1.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = datagridview1.Rows[selectedrowindex];
string cellValue = Convert.ToString(selectedRow.Cells["enter column name"].Value);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…