这是dataGridView的选择更改事件,它会触发三次,并导致用于选择特定行单元格值的代码出错:
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
int i;
i = dataGridView1.SelectedCells[0].RowIndex;
lblIdValue.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
}