Hello,
I have a DataGrid(View) and a DataTable. The DataTable is displayed in the
DataGridView:
dataGridView.Da taSource = theTable;
The user is allowed to select some rows and then the following
snippet updates some values in the selected rows:
foreach (DataGridViewRo w row in dataGridView.Se lectedRows)
{
row.Cells["theColumnName1 "].Value = someCalculatedV alue1;
row.Cells["theColumnName2 "].Value = someCalculatedV alue2;
}
Then the following line of code is executed:
MessageBox.Show (theTable.GetCh anges().Rows.Co unt.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.GetCha nges()...
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.Da taSource = theTable;
The user is allowed to select some rows and then the following
snippet updates some values in the selected rows:
foreach (DataGridViewRo w row in dataGridView.Se lectedRows)
{
row.Cells["theColumnName1 "].Value = someCalculatedV alue1;
row.Cells["theColumnName2 "].Value = someCalculatedV alue2;
}
Then the following line of code is executed:
MessageBox.Show (theTable.GetCh anges().Rows.Co unt.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.GetCha nges()...
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
Comment