0

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...)

T30
  • 11,422
  • 7
  • 53
  • 57
  • The only way I've found is to call `AnotherObject.Focus()` before checking `HasChanges`, and then re set the focus to the dgv... But it isn't marvelous... – T30 Jan 09 '14 at 11:09

1 Answers1

0

Use this before menu opens:

dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
Arin Ghazarian
  • 5,105
  • 3
  • 23
  • 21
  • I've tried to put this line in the menu's onClick event, but still doesn't work... – T30 Jan 09 '14 at 13:24