foreach (DataGridViewRow dgvRow in datagridview1.Rows)
{
if (dgvRow != null)
{
int qty = dgvRow.Cells["数量1"].Value.ToString().Trim();
int inventoryQty =dgvRow.Cells["数量2"].Value.ToString().Trim();
if (inventoryQty < qty)
{
//验收数量少时呈淡蓝色
dgvRow.DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (qty == inventoryQty)
{
//正常呈白色
dgvRow.DefaultCellStyle.BackColor = Color.White;
}
else
{
//验收数量多时呈红色
dgvRow.DefaultCellStyle.BackColor = Color.MistyRose;
}
}
}
浙公网安备 33010602011771号