计算具有特定值的单元格数

Calculate number of cells with a specific value

我正在创建一个具有统计功能的测试管理程序,它可以计算已修复、未修复或 N/A 的错误数量。 测试用例都列在 DataGridView 上,其中第一列用于测试用例,第二列用于结果(我想使用的列),后者仅用于注释。 这是我的一些代码来展示我在说什么

private int Passed() // This method is supposed to count how many test cases have passed
    {
        int passed = 0;
        if (/*what condition should I put here?*/) {
            passed++;
        }
        return passed;
    }

    //Is this the best way to display the percentage in real time?
    private void Refresh_Tick(object sender, EventArgs e)
    {
        Display2.Text = Passed().ToString();
    }

"Results" 列单元格各有一个组合框,其项目为 "FIXED"、"N/A" 和 "NOT FIXED"。 拜托,我想知道如何以编程方式访问这些单元格的值,然后将它们用作计算已修复错误数量的条件。

遍历 gridview 中的所有行应该可以找到答案。

int countFixed=0;
int countUnFixed=0;
for(int i=0;i<dgv.RowCount;i++)
{
   if((string)dgv.Rows[i].Cells[1].Value == "Fixed") //try referring to cells by column names and not the index 
      countFixed++;
   else if((string)dgv.Rows[i].Cells[1].Value == "Not Fixed")
      countUnFixed++;
}