[RESOLVED] DataSet.HasChanges not firing unless you leave row
When you edit a cell in a datagrid, how can you "commit" that change if you are still in that current cell? Right now, the DataSet.HasChanges property isn't true UNTIL you leave the current cell. If you don't click on another row, then the property is not true yet. How can I tell it that it is true without physically clicking on another cell?
Re: DataSet.HasChanges not firing unless you leave row
Is it a datagrid or DataGridView? If it's the later, you can call the Commit method on the DGV to force it to commit the changes to its datasource. However, you're biggest problem is to detect when to call the method unless you have something to look for, such as the enter key...
Re: DataSet.HasChanges not firing unless you leave row
I am using a datagridview control in a windows form. There is no Commit method that I see. There is a CommitEdit, which I have tried, but it seems to have no effect. I just have that one control by itself on the form and wish to check for changes and prompt to save if there are (only other controls are menu items), and it is working, unless you only make one change and do not leave the row. It doesn't prompt since the Dataset.HasChanges property is not true.
Re: DataSet.HasChanges not firing unless you leave row
Yeah, I meant the CommitEdit method... From the sound of what you are doing, you may want to test the DGV.IsCurrentRowDirty property, and if it is, you call the form's Validate method to commit the changes to the datasource. If the datasource is a bindingsource, you can call BS.EndEdit instead.
Re: DataSet.HasChanges not firing unless you leave row
That seems to be the step I was missing, calling .Validate on the form after ending the edits. Thanks.