tags:

views:

309

answers:

1

I have a form with a databound DataGridView. I use IDataError interface to handle errors and it works perfect, showing red marking in row header of rows with errors..

But how do I get the cursor to jump to the first row with error(s).

Thanks in advance..

+2  A: 

Presumably, by iterating them?

    foreach(DataGridViewRow row in view.Rows)
    {
        IDataErrorInfo dei = row.DataBoundItem as IDataErrorInfo;
        if (dei != null && !string.IsNullOrEmpty(dei.Error))
        {
            if(row.Cells.Count > 0) view.CurrentCell = row.Cells[0];
            view.FirstDisplayedScrollingRowIndex = row.Index;
            break;
        }
    }
Marc Gravell