Thanks Mohd. Mukhtar!
I get "Row associated with the currency manager's position cannot be made invisible" error.
The reason for this particular error is that we cannot make modifications to a row at runtime which is bound to datasource, unless we suspened the binding on all rows using CurrencyManager object by adding grd1.CurrentCell = null.
public void btnSearch_Click(object sender, EventArgs e)
{
grd1.ClearSelection();
string search = txtSearch.Text;
for (int i = 0; i < grd1.Rows.Count - 1; i++)
{
for (int j = 0; j < grd1.Columns.Count; j++)
{
if(grd1.Rows[i].Cells[0].Value.ToString().ToLower().Contains(search.ToLower()))
{
break;
}
if(j == (grd1.Columns.Count-1))
{
grd1.CurrentCell = null;
grd1.Rows[i].Visible = false;
}
}
}
}