I have two DataGridViews, A and B, and one DataSet "D" with two tables "tA" and "tB" identical in structure. Each DataGridView is connected to its respective table by its own BindingSource.
One of the columns, named "Complete", contains checkboxes to mark a data row as "Complete". When such a checkbox in DataGridView A is checked by the user, I want to immediately move that datarow from dgv A to dgv B. I've accomplished this using the eventhandling code below
void datagridviewA_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (datagridviewA.IsCurrentCellDirty)
{
datagridviewA.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
void datagridviewA_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 11) // 11 is the column index containing the "complete" checkboxes
{
tB.ImportRow(tA.Rows[e.RowIndex]);
tA.Rows.RemoveAt(e.RowIndex);
}
}
This works to move the row from dgv A to dgv B, but I expected the "complete" checkbox cell to be checked in dgv B, but it's not. It's as if the row is being imported from tA before tA is updated to reflect the "checked" status of the checkbox.
How can I move the row and keep the checkbox checked as expected?
Thanks,