G
Guest
Hello,
I have a DataGrid(View) and a DataTable. The DataTable is displayed in the
DataGridView:
dataGridView.DataSource = theTable;
The user is allowed to select some rows and then the following
snippet updates some values in the selected rows:
foreach (DataGridViewRow row in dataGridView.SelectedRows)
{
row.Cells["theColumnName1"].Value = someCalculatedValue1;
row.Cells["theColumnName2"].Value = someCalculatedValue2;
}
Then the following line of code is executed:
MessageBox.Show(theTable.GetChanges().Rows.Count.ToString());
It turns out that the number of rows returned by GetChanges() is always one
lower than the number of selected rows in the DataGridView. When n rows are
selected, the foreach loop is executed for n rows, n rows change in the
DataGridView, but only n-1 rows are returned by theTable.GetChanges()...
Updating complete rows at once in the DataGridView using row.SetValues(...)
doesn't make a difference. The last selected row, though changed in the
DataGridView, is never actually changed in the DataTable.
Could anyone help me out please?
Thanks a lot!
Jochen
I have a DataGrid(View) and a DataTable. The DataTable is displayed in the
DataGridView:
dataGridView.DataSource = theTable;
The user is allowed to select some rows and then the following
snippet updates some values in the selected rows:
foreach (DataGridViewRow row in dataGridView.SelectedRows)
{
row.Cells["theColumnName1"].Value = someCalculatedValue1;
row.Cells["theColumnName2"].Value = someCalculatedValue2;
}
Then the following line of code is executed:
MessageBox.Show(theTable.GetChanges().Rows.Count.ToString());
It turns out that the number of rows returned by GetChanges() is always one
lower than the number of selected rows in the DataGridView. When n rows are
selected, the foreach loop is executed for n rows, n rows change in the
DataGridView, but only n-1 rows are returned by theTable.GetChanges()...
Updating complete rows at once in the DataGridView using row.SetValues(...)
doesn't make a difference. The last selected row, though changed in the
DataGridView, is never actually changed in the DataTable.
Could anyone help me out please?
Thanks a lot!
Jochen