我想用条件更改DataGridView行的颜色 当我添加两行具有相同值的错误时:
指数超出范围。必须是非负数且小于集合的大小。
细节
姓名:
DataGridView:dgv_ListZamen
表:tbl_TedadZemanat
专栏:TedadZemanatRasmi,TedadZemanatPimankari
private void pictureBox_ben_Click(object sender, EventArgs e)
{
if(dgv_listZamen.RowCount != 0)
{
var query = db.tbl_TedadZemanats.Where(c => c.TedadZemanatRasmi.Value + c.TedadZemanatPimankari.Value > 2).ToList();
string a = query.Select(c => c.Id.ToString()).FirstOrDefault();
int b = Convert.ToInt32(a);
dgv_listZamen.Rows[b].DefaultCellStyle.BackColor = Color.Red;
}
}