DataGridView does not save last change even I CommitEdit; But if I click somewhere else, it saves!

R

Ryan Liu

I found DataGridView in .NET 2.0 has a bug, or maybe I used it in a wrong
way, just try to confirm with you guys:

I have a checkbox column in it, and a save button on the form try to save
changes made by this checkbox column.

But the state of last checkbox is always not saved, unless I click somewhere
else on the form.

//all of these line code does not help!!!!
if (this.dgvProject.IsCurrentCellInEditMode)
{
this.dgvProject.EndEdit(); //I know this will commit
}
if (this.dgvProject.IsCurrentCellDirty)
{
this.dgvProject.CommitEdit(DataGridViewDataErrorContexts.Commit);
//just try again
}
this.dsPowerCapi.project.AcceptChanges();

//delete above lines, and replaced with this single line, it works, all
changes are saved!!!
this.rtbGreeting.Focus();//a fake line is needed to make
sure last change also saved




//code after ....

this.projectTableAdapter.Update(this.dsPowerCapi.project);

this.changed = false;
this.tsbSave.Enabled = this.changed;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top