The code:
/// <summary>
/// This happens AFTER the rows have been added, but BEFORE the CurrentRow has been changed. Therefore you can't use the currentRow to
/// find out where you are pointing. The e.Rowindex is WRONG when you add rows programmatically. Had to use ROWCOUNT instead.
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void purchase_Order_DetailDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
if (!isFetchingData)
{
DataGridView Grid = (sender as DataGridView);
int lastrow = Grid.RowCount-1;
if (lastrow > 0)
{
DataGridViewCell Cell= Grid.Rows[lastrow].Cells["Pick"];
Grid.CurrentCell = Grid.Rows[lastrow].Cells["Pick"];
Grid.BeginEdit(true);
}
}
}The Result:
It seems the correct cell is "Selected" but the cursor is in the previous row,
So, there are 2 rows, 0 and 1, and 1 should be "Current". The debugger confirms.
Yet the "Cursor" is still in Row 0.
I have tried refreshing the grid at various places to null effect.
The desired behavior is to have the cursor in the new row in the "Pick" column after an add (Add row button pressed).
I'd rather live with false hope than with false despair.