I found the answer in this article: http://www.c-sharpcorner.com/Forums/Thread/43898/
Selecting the row is not enough, you have to set the CurrentCell to make the row become the CurrentRow. So to make the code above work, you have to change this:
public void addItem()
{
item i = new item(myItems.Count + 1);
myItems.Add(i);
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
if (dr.DataBoundItem == i)
{
dr.Selected = true;
}
}
}
to that:
public void addItem()
{
item i = new item(myItems.Count + 1);
myItems.Add(i);
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
if (dr.DataBoundItem == i)
{
dr.Selected = true;
dataGridView1.CurrentCell = dr.Cells[0];
}
}
}