iirc a datagridview row has a visible property eg dataGridView.Rows[Index].Visible = [false|true];
so could you do this perhaps ?
foreach (DataGridViewRow row in dgvVV1111.Rows)
{
int X = Convert.ToInt32(row.Cells["TotalAmount"].Value);
if (X == 0)
{
row.DefaultCellStyle.BackColor = Color.Red;
}
else
{
row.Visible = false;
}
}
(You might need intellisense to check for the Visible property, this is a dim recollection) .. if it works you could add a button to show all rows by setting all Visible to true
[Edit] I think, depending on what else you need to do, you would be better off with a bindingsource and filter.
Some useful references may be
A Detailed Data Binding Tutorial[
^],
Summary DataGridView[
^] and
DataGrid with built-in filter functionality[
^] [/Edit]