Chuck P
2006-09-21 18:52:43 UTC
I have a DataGridView where the user can make changes.
When he goes to quit he can either save or discard the changes.
I don't know if this is the best way to do it but I wrote
(this.BindingSource.DataSource as DataSet).RejectChanges();
object tempDataSource =dataGridView1.DataSource;
dataGridView1.DataSource = null;
dataGridView1.DataSource = tempDataSource;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
dataGridView1.Rows[i].ErrorText = "";
dataGridView1.Refresh();
The original values are back in the grid but the error text/icon
remains.
p.s. I know that if their is an error in the dataset that the error
automatically gets put in the dataGridView1.Rows[i].ErrorText and
that trying to clear it doesn't work. You have to clear it from the
datarowview. So maybe RejectChanges is not clearing the error text in
the dataset?
When he goes to quit he can either save or discard the changes.
I don't know if this is the best way to do it but I wrote
(this.BindingSource.DataSource as DataSet).RejectChanges();
object tempDataSource =dataGridView1.DataSource;
dataGridView1.DataSource = null;
dataGridView1.DataSource = tempDataSource;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
dataGridView1.Rows[i].ErrorText = "";
dataGridView1.Refresh();
The original values are back in the grid but the error text/icon
remains.
p.s. I know that if their is an error in the dataset that the error
automatically gets put in the dataGridView1.Rows[i].ErrorText and
that trying to clear it doesn't work. You have to clear it from the
datarowview. So maybe RejectChanges is not clearing the error text in
the dataset?