I found DataGridView in .NET 2.0 has a problem, 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.dgvProjec t.IsCurrentCell InEditMode)
{
this.dgvProject .EndEdit(); //I know this will commit
}
//just try again
if (this.dgvProjec t.IsCurrentCell Dirty)
{
this.dgvProject .CommitEdit(Dat aGridViewDataEr rorContexts.Com mit);
}
this.dsPowerCap i.project.Accep tChanges();
//delete above lines, and replaced with this single line, it works, all
changes are saved!!!
this.rtbGreetin g.Focus();//a fake line is needed to make
sure last change also saved
//code after ....
this.projectTab leAdapter.Updat e(this.dsPowerC api.project);
this.changed = false;
this.tsbSave.En abled = this.changed;
Thanks!
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.dgvProjec t.IsCurrentCell InEditMode)
{
this.dgvProject .EndEdit(); //I know this will commit
}
//just try again
if (this.dgvProjec t.IsCurrentCell Dirty)
{
this.dgvProject .CommitEdit(Dat aGridViewDataEr rorContexts.Com mit);
}
this.dsPowerCap i.project.Accep tChanges();
//delete above lines, and replaced with this single line, it works, all
changes are saved!!!
this.rtbGreetin g.Focus();//a fake line is needed to make
sure last change also saved
//code after ....
this.projectTab leAdapter.Updat e(this.dsPowerC api.project);
this.changed = false;
this.tsbSave.En abled = this.changed;
Thanks!