Just use the following...

try
{
//put you code here
}
catch
{
//do nothing if error occurs
}

The try catch block works great. It will work just like "On Error Resume Next"

Example...

for(int row = 0; row < rowCount; row++)
{
try
{
myDataGrid1.UnS elect(row);
...