views:

20

answers:

1

I have the following code. When i refresh my datagrid the row select is still select (note i only have one select row at a time which is why selectIndex is one value and not a list).

The problem is when i move my arrowkey up or down it starts from the beginning of the datagridview and not the row selected.

            var ret = dataGridView1.Rows.Add(r.orderNo, r.link, r.status);
            dataGridView1.Rows[ret].Tag = r;
            if (r.id == selectIndex)
            {
                dataGridView1.Rows[ret].Selected = true;
            }
A: 

This seems to solve your problem:

    void SelectGridRow( int rowIndex )
    {
        _grid.Rows[ rowIndex ].Cells[ 0 ].Selected = true;
    }
Adel Hazzah