I have a WinForms app with a datagridview and a bindingsource. I want the user to confirm changes before I save them to the database.
I don’t want to pop up the confirmation dialog unless I know the user has made changes. So I need a way to check if changes have been made. Any suggestions?
You should be able to use
BindingSource.ListChangedto rig a crude test – set a flag when the event is fired (you’ll probably have to clear the flag once binding has completed).But what is the data? For example, LINQ-to-SQL and DataTable both offer ways of querying for changes… (
DataTable.GetChanges()andDataContext.GetChangeSet()). Most DAL-based mechanisms will usually have a way to do this too.