隐藏具有特定单元格值的行DataGridView C#

use*_*982 6 datagridview rows hide

我在隐藏0有价值的行时遇到问题DataGridView.

foreach (DataGridViewRow row in this.taggGrid.Rows)
{
    if (Convert.ToString(row.Cells[4].Value).Equals(0))
    {
        row.Visible = false;
    }
}
Run Code Online (Sandbox Code Playgroud)

我要隐藏的行仍显示.

Bri*_*汤莱恩 5

(由 OP 在编辑中回答。请参阅没有答案的问题,但问题已在评论中解决(或在聊天中扩展)

OP写道:

回答: 自己解决了:

foreach (DataGridViewRow dr in taggGrid.Rows)
        {
            if (dr.Cells[4].Value.ToString() == "False")
            {
                dr.Visible = false;
            }
        }
Run Code Online (Sandbox Code Playgroud)