Hi, having a hard time with bindingsource.EndEdit() and _FormClosing event of my WinForm.
Scenario:
- dataset (ds) loaded via ds.ReadXml(<filename>)
- bindingsource (bs) bs.Datasource = ds
- datagridview (dgv) dgv.Datamember pointing to a table in dataset ds.
so far so good, I do see the data....
Upon closing the form (red X) I would like to see if there are pending changes.
Therefor in my _FormClosing event handler I
- Call first bs.EndEdit()
- Test dataset: ds.HasChanges()
Observation:
- When I change a cell in my datagridview and click "X" before leaving the datagridview: HasChanges() is false ---> Not OK !
- When I change a cell in my datagridview, shift focus to another control and then click "X": HasChanges() is true --> OK
Things I tried:
- When doing the same in a click event handler of another button: HasChanges() gives in both cases: TRUE (correct)
- When I put in my _FormClosing eventhandler a statement like: <another control>.focus = true, all is also fine.
Seems that .EndEdit() in _FormClosing event handlers are not processed correctly ? or did I do something stupid :-)
Thanks for your input...
Boris
p.s. Using Visual C# 2008 Express