dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Gold;第一次无效
private void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{}//修改
DataGridViewCellStyle sty=new DataGridViewCellStyle();
dgv.Rows[e.RowIndex].DefaultCellStyle = sty;