如果行里面有特定的单词,我想隐藏特定的单元格

I want to hide specific cells if rows got specific word inside

我想隐藏特定的单元格,但如果行内有 x 字。

来自

this is mydatagridview

this is what i want

遍历行并测试值:

foreach(DataGridViewRow row in myDatagridview.Rows)
{
    if(row.Cells["y"].Value == "a")
    {
        row.Visible = false;
    }
}

如果要比较字符串值

,则可能需要在 row.Cells["y"].Value 之后添加 .ToString()

由于您只想隐藏值而不是整行,只需将 row.Visible = false 替换为 row.Cells["x"].Value = null