Hi!

i tried to iterate the DataGrid Control with below code:

Code:
String strSelDvdCat = cbDvdCat.SelectedItem.ToString();
            String strCat;
            int irowindex = 0;


            foreach (DataGridViewRow row in dgvViewDvds.Rows)
            {
                try
                {
                    DataGridViewCell cell = row.Cells[2];//Cat colum (2)

                    strCat = cell.Value.ToString();

                    //if (!(strSelDvdCat.ToLower().Contains(strCat.ToLower())))
                    {
                        dgvViewDvds.Rows.RemoveAt(irowindex);
                        MessageBox.Show(irowindex.ToString());

                    }
                    irowindex++;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
The foreach() loops only about 4 times when i have 10 rows in the DataGrid. And then it gives the exception "Object reference not set to an instance", and quits the loop. Why does the loop stop prematurely?

Thanks for any help.