如图,表格是用dataGridView1做的,我想在红色那里做个总判断:
如果Result那一列1到8全部为pass,红色就pass,否则fail.
现在我这样判断:
if (dataGridView1.Rows[0].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[1].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[2].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[3].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[4].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[5].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[6].Cells[3].Value.ToString() == "pass" &&
dataGridView1.Rows[7].Cells[3].Value.ToString() == "pass")
应该很不好,但是该怎么做呢?
遍历dataGridView1行数 dataGridView1.Rows.[Count|Length],用一个全局变量保存是否有不为pass,如有不为pass的,就显示fail,否则就pass
不存在dataGirdView1.Rows.Length,提示说未包含
Length
的定义,我用vs2015
一个for循环不就可以了么?