DataSet.HasChanges not work for selected row (onClick MenuStrip)

405 Views Asked by At

I have a datagridview binded with MyDataSet.

At form load, I fill the datagridview with this command:

MyTableAdapter.Fill(this.MyDataSet.ExtractData);

Now, I've added a MenuStrip and I want to get MyDataSet changes when I click on File/Save, but if I change only one row and that row remains selected, when I click File/Save no change is detected, and MyDataSet.HasChanges() always returns false.

MyDataSet.HasChanges() returns true only if I click on a button or another form object, not if I click on MenuStrip.

Why? There is a workaround? (I've tried to call EndEdit on the Dgv and to update the dataSet, but does not work...)

1

There are 1 best solutions below

1
On

Use this before menu opens:

dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);