Reputation: 1729
How do I set the arrow to the selected row. I'm programatically selecting the rows based on the value of a combo box. Currently, only the row is highlighted and the arrow doesn't follow
foreach (DataGridViewRow row in dgv.Rows)
{
if ((int)row.Tag == ma.ID)//ma.ID is the selected combo box value
{
row.Selected = true;
}
}
Upvotes: 0
Views: 1572
Reputation: 1421
You have to change CurrentCell
like this.
(This will also change CurrentRow
)
foreach (DataGridViewRow row in dgv.Rows)
{
if ((int)row.Tag == ma.ID)//ma.ID is the selected combo box value
{
row.Selected = true;
dgv.CurrentCell = row.Cells[0];
}
}
Upvotes: 2