Results 1 to 3 of 3

Thread: [RESOLVED] Cancel Changes with BindingSource

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2004
    Posts
    263

    Resolved [RESOLVED] Cancel Changes with BindingSource

    I have a datagridview bound to a bindingsource which has a datatable (an access mdb file) as the underlying data storage.

    I've been saving changes like this (which seems to be working fine):
    Code:
            EventBindingSource.EndEdit() 'apply changes to underlying datasource
            EventTableAdapter.Update(TimetrackerDataSet)
    Now if the user selects to NOT save the changes, I tried to do this:
    Code:
                    EventBindingSource.CancelEdit()
                    'EventBindingSource.ResetCurrentItem()
                    'EventBindingSource.ResetBindings(False)
                    EventTableAdapter.Update(TimetrackerDataSet)
    And it indeed does not save the changes to the database, but if I am still working in the datagridview and happen to call up the record that was edited again, the changes are still there. If I close the form and reopen it then the changes are gone (like they should be).

    Is there a more direct way to say "forget everything since the last save and make the datagridview reflect that"?

    Thanks

    Dave

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: Cancel Changes with BindingSource

    what about rebinding the gridview with the copy of the Original datatable !
    __________________
    Rate the posts that helped you

  3. #3
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Cancel Changes with BindingSource

    Call RejectChanges on the underlying datatable.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width