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;
                    }
                }
            }

posted on 2013-08-22 15:41  清风暮雨  阅读(180)  评论(0)    收藏  举报